|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.synth.graph.SubsetIterator
A class that supports iteration over a subset of elements in another iterator. The SubsetIterator class provides a convenient mechanism for accessing a set of elements in an iterator that meet some selection criteria. The contains method of a SubsetSelector is used to specify the selection criteria.
For example, if you had an iterator of objects with some numeric value associated with each element, and you were only interested in the elements with positive values you could do something like this:
// elements is an iterator containing NumericValue objects of arbitrary values SubsetIterator positiveElements = new SubsetIterator(elements, new PositiveSelector); // where PositiveSelector could be defined as: class PositiveSelector implements SubsetSelector { public boolean contains(Object elt) { if (elt instanceof NumericValue) { return (((NumericValue) elt).getValue() > 0); else return false; }
SubsetSelector
Field Summary | |
protected GenericIterator |
iterator
|
protected SubsetSelector |
selector
|
Constructor Summary | |
SubsetIterator(GenericIterator iterator,
SubsetSelector selector)
Construct a new SubsetIterator that will iterate over the items in iterator for which selector.contains() returns true. |
Method Summary | |
boolean |
deleteElt()
Remove the current element from the series. |
GenericIterator |
first()
Move this iterator's "pointer" to the first element in the subset. |
java.lang.Object |
getElt()
Retrieves the object currently pointed at by the iterator. |
boolean |
isValid()
Checks if the iterator currently points to a valid item in the series. |
GenericIterator |
last()
Move this iterator's "pointer" to the last element in the subset. |
boolean |
moveTo(java.lang.Object elt)
Moves the iterator to the specified element. |
GenericIterator |
next()
Moves the iterator to the next element in the subset. |
GenericIterator |
prev()
Moves the iterator to the previous element in the subset. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected GenericIterator iterator
protected SubsetSelector selector
Constructor Detail |
public SubsetIterator(GenericIterator iterator, SubsetSelector selector)
iterator
- An iterator that contains elements of interest.selector
- A SubsetSelector whose contains method identifies
the elements of interest in iterator.Method Detail |
public GenericIterator first()
first
in interface GenericIterator
public GenericIterator last()
last
in interface GenericIterator
public boolean isValid()
isValid
in interface GenericIterator
public GenericIterator next()
next
in interface GenericIterator
public GenericIterator prev()
prev
in interface GenericIterator
public boolean moveTo(java.lang.Object elt)
moveTo
in interface GenericIterator
public java.lang.Object getElt()
getElt
in interface GenericIterator
public boolean deleteElt()
Also Note: Any modifications of the series of elements, (ie. deletes or modifications), other than through this iterator may cause undefined effects on the state of this iterator.
deleteElt
in interface GenericIterator
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |