Package generic.stl
Class VectorIterator<T>
- java.lang.Object
-
- generic.stl.VectorIterator<T>
-
- All Implemented Interfaces:
IteratorSTL<T>
public class VectorIterator<T> extends java.lang.Object implements IteratorSTL<T>
-
-
Constructor Summary
Constructors Constructor Description VectorIterator(java.util.ArrayList<T> data, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(IteratorSTL<T> otherIterator)'Assigns' this iterator to be equivalent to the given iterator.IteratorSTL<T>copy()Creates a copy of this iterator.IteratorSTL<T>decrement()Devance the iterator to the previous position.IteratorSTL<T>decrement(int count)Devances the iterator n positions.booleanequals(java.lang.Object obj)Tget()Returns the current value of the iterator.Tget(int offset)intgetIndex()inthashCode()IteratorSTL<T>increment()Advances the iterator to the next position.IteratorSTL<T>increment(int count)Advances the iterator n positions.voidinsert(T value)Inserts the given value at the current position (the current value will be pushed to the next value).booleanisBegin()Returns true if the iterator is positioned on the first first element of the collection.booleanisEnd()Returns true if the iterator is positioned past the last element of the collection.voidset(T value)Sets the current value of the iterator to the given value.java.lang.StringtoString()
-
-
-
Field Detail
-
index
protected int index
-
data
protected java.util.ArrayList<T> data
-
-
Constructor Detail
-
VectorIterator
public VectorIterator(java.util.ArrayList<T> data, int index)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
assign
public void assign(IteratorSTL<T> otherIterator)
Description copied from interface:IteratorSTL'Assigns' this iterator to be equivalent to the given iterator. This is equivalent to C++'s '=' overloading mechanism- Specified by:
assignin interfaceIteratorSTL<T>- Parameters:
otherIterator- The iterator to copy
-
isBegin
public boolean isBegin()
Description copied from interface:IteratorSTLReturns true if the iterator is positioned on the first first element of the collection. If the collection is empty, this will always return false.- Specified by:
isBeginin interfaceIteratorSTL<T>- Returns:
- true if the iterator is positioned on the first element of the collection.
-
isEnd
public boolean isEnd()
Description copied from interface:IteratorSTLReturns true if the iterator is positioned past the last element of the collection. If the collection is empty, this will always return true.- Specified by:
isEndin interfaceIteratorSTL<T>- Returns:
- true if the iterator is positioned past the last element of the collection.
-
get
public T get()
Description copied from interface:IteratorSTLReturns the current value of the iterator.- Specified by:
getin interfaceIteratorSTL<T>- Returns:
- the current value of the iterator.
-
set
public void set(T value)
Description copied from interface:IteratorSTLSets the current value of the iterator to the given value.- Specified by:
setin interfaceIteratorSTL<T>- Parameters:
value- the value to set at the iterator position
-
get
public T get(int offset)
-
decrement
public IteratorSTL<T> decrement()
Description copied from interface:IteratorSTLDevance the iterator to the previous position. This method is only supported in bidirectional iterators.- Specified by:
decrementin interfaceIteratorSTL<T>- Returns:
- a reference to the iterator itself
-
increment
public IteratorSTL<T> increment()
Description copied from interface:IteratorSTLAdvances the iterator to the next position.- Specified by:
incrementin interfaceIteratorSTL<T>- Returns:
- a reference to the iterator itself
-
increment
public IteratorSTL<T> increment(int count)
Description copied from interface:IteratorSTLAdvances the iterator n positions.- Specified by:
incrementin interfaceIteratorSTL<T>- Returns:
- a reference to the iterator itself
-
decrement
public IteratorSTL<T> decrement(int count)
Description copied from interface:IteratorSTLDevances the iterator n positions.- Specified by:
decrementin interfaceIteratorSTL<T>- Returns:
- a reference to the iterator itself
-
insert
public void insert(T value)
Description copied from interface:IteratorSTLInserts 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.- Specified by:
insertin interfaceIteratorSTL<T>- Parameters:
value- the value to insert into the collection.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
copy
public IteratorSTL<T> copy()
Description copied from interface:IteratorSTLCreates a copy of this iterator.- Specified by:
copyin interfaceIteratorSTL<T>- Returns:
- a copy of this iterator.
-
getIndex
public int getIndex()
-
-