|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--lava.util.EnumerationLookaheadWindow
An EnumerationLookaheadWindow provides the user with a "sliding window" into an Enumeration. This lets the user "peek ahead" into the Enumeration while searching for specific Objects. A window_size parameter, specified when the window is initialized, determines the extent the window can look ahead into the Enumeration.
When an EnumerationLookaheadWindow is initialized, the window is filled by consuming objects from the Enumeration. Objects that have entered the window can be accessed without removing them (otherwise, it wouldn't be much of a "lookahead" window, would it?). Additionally, Objects in the window can be removed in random order; it is not necessary to always consume the first Object in the window. When an Object is removed, other Objects in the window "slide over" to fill the hole. The hole at the end of the window, of course, is filled by reading another Object from the Enumeration.
| Field Summary | |
protected java.util.Enumeration |
en
|
protected FifoQueue |
queue
|
protected int |
window_size
|
| Constructor Summary | |
EnumerationLookaheadWindow(java.util.Enumeration en,
int window_size)
Creates a new window into the given Enumeration, using the given window size. |
|
| Method Summary | |
java.lang.Object |
elementAt(int pos)
Returns the entry at the given position without removing it. |
int |
elementsWaiting()
Returns the number of elements waiting in the window. |
protected void |
fill()
Fills the window with new elements from the Enumeration. |
protected void |
fillOne()
Adds one more element to the queue. |
boolean |
hasMoreElements()
Indicates whether this enumeration has more elements. |
java.lang.Object |
nextElement()
Returns the next element. |
java.lang.Object |
removeElementAt(int pos)
Removes the entry at the given position in the window and returns it. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.Enumeration en
protected FifoQueue queue
protected final int window_size
| Constructor Detail |
public EnumerationLookaheadWindow(java.util.Enumeration en,
int window_size)
en - the Enumerationwindow_size - the size of the lookahead window| Method Detail |
protected final void fill()
protected final void fillOne()
Details: fillOne consumes an Object from the Enumeration and places it at the end of the look-ahead window.
public java.lang.Object removeElementAt(int pos)
pos, is considered "out of bounds" if (pos < 0 || pos >= size ()). If pos is out of bounds, a NoSuchElementException is thrown.pos - the positionjava.util.NoSuchElementException - if pos is invalidpublic java.lang.Object elementAt(int pos)
pos, is considered "out of bounds" if (pos < 0 || pos >= size ()). If pos is out of bounds, a NoSuchElementException is thrown.pos - the positionpublic int elementsWaiting()
public java.lang.Object nextElement()
Details: DETAILS FORTHCOMING
nextElement in interface java.util.Enumeration - - public boolean hasMoreElements()
hasMoreElements in interface java.util.Enumeration
|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||