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 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 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
    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.
  • 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

      void set(T value)
      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

      IteratorSTL<T> increment(int n)
      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

      IteratorSTL<T> decrement(int n)
      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

      void insert(T value)
      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

      void assign(IteratorSTL<T> otherIterator)
      'Assigns' this iterator to be equivalent to the given iterator. This is equivalent to C++'s '=' overloading mechanism
      Parameters:
      otherIterator - The iterator to copy