Package generic.stl
Interface IteratorSTL<T>
- All Known Implementing Classes:
EmptyIteratorSTL
,ListIterator
,MapIteratorSTL
,ReverseMapIteratorSTL
,ReverseSetIterator
,SetIterator
,UnmodifiableListIteratorSTL
,VectorIterator
public interface IteratorSTL<T>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assign
(IteratorSTL<T> otherIterator) 'Assigns' this iterator to be equivalent to the given iterator.copy()
Creates a copy of this iterator.Devance the iterator to the previous position.decrement
(int n) Devances the iterator n positions.get()
Returns the current value of the iterator.Advances the iterator to the next position.increment
(int n) Advances the iterator n positions.void
Inserts the given value at the current position (the current value will be pushed to the next value).boolean
isBegin()
Returns true if the iterator is positioned on the first first element of the collection.boolean
isEnd()
Returns true if the iterator is positioned past the last element of the collection.void
Sets the current value of the iterator to the given value.
-
Method Details
-
get
T get()Returns the current value of the iterator.- Returns:
- the current value of the iterator.
- Throws:
IndexOutOfBoundsException
- if the iterator is positioned before the first value or after the last value.
-
set
Sets the current value of the iterator to the given value.- Parameters:
value
- the value to set at the iterator position- Throws:
IndexOutOfBoundsException
- if the iterator is positioned befor the first value or after the last value.
-
increment
IteratorSTL<T> increment()Advances the iterator to the next position.- Returns:
- a reference to the iterator itself
- Throws:
IndexOutOfBoundsException
- if the the iterator is already past the last element.
-
increment
Advances the iterator n positions.- Returns:
- a reference to the iterator itself
- Throws:
IndexOutOfBoundsException
- if the n value pushes past the end of the collection.
-
decrement
IteratorSTL<T> decrement()Devance the iterator to the previous position. This method is only supported in bidirectional iterators.- Returns:
- a reference to the iterator itself
-
decrement
Devances the iterator n positions.- Returns:
- a reference to the iterator itself
- Throws:
IndexOutOfBoundsException
- if the n value pushes past the beginning of the collection
-
isBegin
boolean isBegin()Returns true if the iterator is positioned on the first first element of the collection. If the collection is empty, this will always return false.- Returns:
- true if the iterator is positioned on the first element of the collection.
-
isEnd
boolean isEnd()Returns true if the iterator is positioned past the last element of the collection. If the collection is empty, this will always return true.- Returns:
- true if the iterator is positioned past the last element of the collection.
-
insert
Inserts the given value at the current position (the current value will be pushed to the next value). The iterator will be positioned on the new value.- Parameters:
value
- the value to insert into the collection.- Throws:
IndexOutOfBoundsException
- if the iterator is positioned before the first item.
-
copy
IteratorSTL<T> copy()Creates a copy of this iterator.- Returns:
- a copy of this iterator.
-
assign
'Assigns' this iterator to be equivalent to the given iterator. This is equivalent to C++'s '=' overloading mechanism- Parameters:
otherIterator
- The iterator to copy
-