clonemethod); similarly, when a user gets a Particle from the queue, he or she supplies a Particle to received the copied value. The advantage of this is that the user need not worry about lifetimes of Particles - when to create them, when it is safe to return them to the Plasma or delete them. The ParticleQueue default constructor forms an empty, unlimited capacity queue. There is also a constructor of the form
ParticleQueue(unsigned int cap);This creates a queue that can hold at most
capparticles. The destructor returns all Particles in the queue to their Plasma.
int empty() const;Return
TRUEif the queue is empty, else
int full() const;Return
TRUEif the length equals the capacity, else
unsigned int capacity() const;Return the queue's capacity. If unlimited, the largest possible unsigned int on the machine will be returned.
unsigned int length() const;Return the number of particles in the queue.
int putq(Particle& p);Put a copy of particle
pinto the queue, if there is room. Returns
FALSEif the queue is already at capacity.
int getq(Particle& p);Get a particle from the queue, and copy it into the user-supplied particle
pis unaltered) if the queue is empty.
void setCapacity(int sz);Modify the capacity to
szis positive or zero. If negative, the capacity becomes infinite.
void initialize();Free up the queue contents. Particles are returned to their pools and the queue becomes empty.
void initialize(int n);Equivalent to