Package generic.stl

Class VectorIterator<T>

java.lang.Object
generic.stl.VectorIterator<T>
All Implemented Interfaces:
IteratorSTL<T>

public class VectorIterator<T> extends Object implements IteratorSTL<T>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ArrayList<T>
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    VectorIterator(ArrayList<T> data, int index)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assign(IteratorSTL<T> otherIterator)
    'Assigns' this iterator to be equivalent to the given iterator.
    Creates a copy of this iterator.
    Devance the iterator to the previous position.
    decrement(int count)
    Devances the iterator n positions.
    boolean
     
    get()
    Returns the current value of the iterator.
    get(int offset)
     
    int
     
    int
     
    Advances the iterator to the next position.
    increment(int count)
    Advances the iterator n positions.
    void
    insert(T value)
    Inserts the given value at the current position (the current value will be pushed to the next value).
    boolean
    Returns true if the iterator is positioned on the first first element of the collection.
    boolean
    Returns true if the iterator is positioned past the last element of the collection.
    void
    set(T value)
    Sets the current value of the iterator to the given value.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • index

      protected int index
    • data

      protected ArrayList<T> data
  • Constructor Details

    • VectorIterator

      public VectorIterator(ArrayList<T> data, int index)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class 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:
      assign in interface IteratorSTL<T>
      Parameters:
      otherIterator - The iterator to copy
    • isBegin

      public boolean isBegin()
      Description copied from interface: IteratorSTL
      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.
      Specified by:
      isBegin in interface IteratorSTL<T>
      Returns:
      true if the iterator is positioned on the first element of the collection.
    • isEnd

      public boolean isEnd()
      Description copied from interface: IteratorSTL
      Returns 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:
      isEnd in interface IteratorSTL<T>
      Returns:
      true if the iterator is positioned past the last element of the collection.
    • get

      public T get()
      Description copied from interface: IteratorSTL
      Returns the current value of the iterator.
      Specified by:
      get in interface IteratorSTL<T>
      Returns:
      the current value of the iterator.
    • set

      public void set(T value)
      Description copied from interface: IteratorSTL
      Sets the current value of the iterator to the given value.
      Specified by:
      set in interface IteratorSTL<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: IteratorSTL
      Devance the iterator to the previous position. This method is only supported in bidirectional iterators.
      Specified by:
      decrement in interface IteratorSTL<T>
      Returns:
      a reference to the iterator itself
    • increment

      public IteratorSTL<T> increment()
      Description copied from interface: IteratorSTL
      Advances the iterator to the next position.
      Specified by:
      increment in interface IteratorSTL<T>
      Returns:
      a reference to the iterator itself
    • increment

      public IteratorSTL<T> increment(int count)
      Description copied from interface: IteratorSTL
      Advances the iterator n positions.
      Specified by:
      increment in interface IteratorSTL<T>
      Returns:
      a reference to the iterator itself
    • decrement

      public IteratorSTL<T> decrement(int count)
      Description copied from interface: IteratorSTL
      Devances the iterator n positions.
      Specified by:
      decrement in interface IteratorSTL<T>
      Returns:
      a reference to the iterator itself
    • insert

      public void insert(T value)
      Description copied from interface: IteratorSTL
      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.
      Specified by:
      insert in interface IteratorSTL<T>
      Parameters:
      value - the value to insert into the collection.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • copy

      public IteratorSTL<T> copy()
      Description copied from interface: IteratorSTL
      Creates a copy of this iterator.
      Specified by:
      copy in interface IteratorSTL<T>
      Returns:
      a copy of this iterator.
    • getIndex

      public int getIndex()