类 CollisionSystem
- java.lang.Object
-
- edu.princeton.cs.algs4.CollisionSystem
-
public class CollisionSystem extends java.lang.Object
TheCollisionSystem
class represents a collection of particles moving in the unit box, according to the laws of elastic collision. This event-based simulation relies on a priority queue.For additional documentation, see Section 6.1 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
-
-
构造器概要
构造器 构造器 说明 CollisionSystem(Particle[] particles)
Initializes a system with the specified collection of particles.
-
-
-
构造器详细资料
-
CollisionSystem
public CollisionSystem(Particle[] particles)
Initializes a system with the specified collection of particles. The individual particles will be mutated during the simulation.- 参数:
particles
- the array of particles
-
-
方法详细资料
-
simulate
public void simulate(double limit)
Simulates the system of particles for the specified amount of time.- 参数:
limit
- the amount of time
-
main
public static void main(java.lang.String[] args)
Unit tests theCollisionSystem
data type. Reads in the particle collision system from a standard input (or generatesN
random particles if a command-line integer is specified); simulates the system.- 参数:
args
- the command-line arguments
-
-