|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
IndexedIterator extends GenericIterator and adds the ability to access items in the series with numeric indexes, (indices?).
Here's an example of using features specific to IndexedIterator in a for loop:
  // Assuming list is a valid object implementing IndexedIterator   for (int i=0; iOf course, you can still use all of the methods that are avaialable in GenericIterator, (first(), next(), isValid(), last(), prev(), etc.)
- Author:
- Carl Worth
Method Summary boolean
deleteEltAt(int index)
Delete the object that has the given index.java.lang.Object
getEltAt(int index)
Retrieves the object at the given index.boolean
moveTo(int index)
Moves the iterator to the element with the given index.int
size()
Returns the number of elements in the series.
Methods inherited from interface byucc.jhdl.synth.graph.GenericIterator deleteElt, first, getElt, isValid, last, moveTo, next, prev
Method Detail moveTo
public boolean moveTo(int index)
- Moves the iterator to the element with the given index.
- Parameters:
index
- an index in the range of 0 <= index < size()- Returns:
- true if pointer was moved to the element at the given index, false if the given index is out of bounds.
getEltAt
public java.lang.Object getEltAt(int index)
- Retrieves the object at the given index. (The current pointer will not be moved.)
- Parameters:
index
- an index in the range of 0 <= index < size()- Returns:
- the object in the series with the given index, null if index is out of bounds.
deleteEltAt
public boolean deleteEltAt(int index)
- Delete the object that has the given index.
After calling delete, this iterator's current "pointer" will not be moved. That is, if the object being deleted is not the "current" object then the pointer will still be pointing to the same element it was before the delete. If, however, the current object is deleted then the pointer will be at an undefined position, (it may even be invalid) -- however, calling next() will move it to the element originally after the deleted element and calling prev() will move it to the element originally before element.
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.
- Parameters:
index
- the index of an element in the series to delete, index should be in the range 0 <= index < size()- Returns:
- true if the object was deleted false if the index is out of bounds
size
public int size()
- Returns the number of elements in the series.
- Returns:
- number of elements in the series.
Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.