|
||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||
See:
Description
| Class Summary | |
| IntQueue | Growable circular queue of ints. |
| ObjectQueue | Growable circular queue of Objects. |
| QueueBase | Base class for type-specific growable circular queue classes with any type of values (including primitive types). |
| StringQueue | Growable circular queue of Strings. |
Type-specific queue collection classes. The classes in this package implement type-specific circular queues based on growable arrays. They support a subset of the normal collection methods, as well as appropriate queue methods. The standard public access methods in these classes are as follows:
| Method Signature | From |
void add(type) | implementation class |
void clear() | QueueBase |
Object clone() | implementation class |
void discard(int) | QueueBase |
void ensureCapacity(int) | GrowableBase |
boolean isEmpty() | QueueBase |
type remove() | implementation class |
int size() | QueueBase |
type[] toArray() | implementation class |
The access methods are unsynchronized for best performance. The user program must implement appropriate locking if multiple threads need to access an instance of these classes while that instance may be modified.
Collections of a primitive type and of a specific object type
are both supported. All variations derive directly from the
QueueBase base class. To define a circular queue of a
new type, generally you can use one of the existing classes as a base
and do a text substitution of the type names.
For instance, to define a circular queue of instances of
Thread just copy StringQueue.java
to a new file named ThreadQueue.java, then do a global
text substitution of "Thread" for "String" in the
new file.
Primitive types are only slightly more complicated. To implement a
circular queue of a primitive type other than the included int,
you're best off basing it on StringQueue.java. If you're doing
this for double, for instance, you'd need to first substitute
"DoubleQueue" for "StringQueue", then "double" for "String". The last step is deleting the
"m_baseArray[index] = null;" line within the remove
method, which is not needed for primitive types.
|
||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||