|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.AbstractStructure<ELTTYPE> structure.AbstractLinear<ELTTYPE> structure.AbstractQueue<ELTTYPE>
public abstract class AbstractQueue<ELTTYPE>
An abstract structure implementing features common to all first-in, first-out structures in this package. Queues are typically used to process values in the order that they appear and to store the state of buffered objects. The structure package provides several implementations of the Queue interface, each of which has its particular strengths and weaknesses.
Example usage:
To compute the sum of the unicode value of every character in the standard input we could use the following:
public static void main(String[] arguments) {AbstractQueue
q = newQueueList()
; int unicodeSum = 0; if(arguments.length > 0){ for(int i=0; i < arguments.length; i++){ for(int j=0; j < arguments[i].length(); j++){ q.enqueue(new Character(arguments[i].charAt(j)))
; } } } while(!q.AbstractLinear.empty()
){ char c = ((Character)q.dequeue()
).charValue(); unicodeSum+=Character.getNumericValue(c); } System.out.println("Total Value: " + unicodeSum); }
QueueArray
,
QueueVector
,
QueueList
Constructor Summary | |
---|---|
AbstractQueue()
|
Method Summary | |
---|---|
ELTTYPE |
dequeue()
Remove a value form the head of the queue. |
void |
enqueue(ELTTYPE item)
Add a value to the tail of the queue. |
ELTTYPE |
getFirst()
Fetch the value at the head of the queue. |
ELTTYPE |
peek()
Fetch the value at the head of the queue. |
Methods inherited from class structure.AbstractLinear |
---|
empty, remove |
Methods inherited from class structure.AbstractStructure |
---|
contains, elements, hashCode, isEmpty, values |
Methods inherited from class java.lang.Object |
---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface structure.Queue |
---|
add, empty, get, remove, size |
Methods inherited from interface structure.Structure |
---|
clear, contains, elements, isEmpty, iterator, remove, values |
Constructor Detail |
---|
public AbstractQueue()
Method Detail |
---|
public void enqueue(ELTTYPE item)
enqueue
in interface Queue<ELTTYPE>
value
- The value added.public ELTTYPE dequeue()
dequeue
in interface Queue<ELTTYPE>
public ELTTYPE getFirst()
getFirst
in interface Queue<ELTTYPE>
public ELTTYPE peek()
peek
in interface Queue<ELTTYPE>
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |