Class ArrayListIter<O>

  • Type Parameters:
    O - contained object type.
    All Implemented Interfaces:
    ArrayIter, It<O>, Iter

    public class ArrayListIter<O>
    extends java.lang.Object
    implements ArrayIter, It<O>
    ELKI style Iterator for array lists.

    Note: this implementation is only efficient for lists with efficient random access and seeking (i.e. ArrayLists, but not Linked Lists!)

    Since:
    0.6.0
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.List<O> data
      The array list to iterate over.
      (package private) int pos
      Current position.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayListIter​(java.util.List<O> data)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ArrayListIter<O> advance()
      Moves the iterator forward to the next entry.
      ArrayListIter<O> advance​(int count)
      Moves the iterator forward or backward by the given offset.
      O get()
      Access the current object.
      int getOffset()
      Get current iterator offset.
      ArrayListIter<O> retract()
      Moves the iterator backward to the previous entry.
      ArrayListIter<O> seek​(int off)
      Moves the iterator to the given position
      boolean valid()
      Returns true if the iterator currently points to a valid object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • data

        final java.util.List<O> data
        The array list to iterate over.
      • pos

        int pos
        Current position.
    • Constructor Detail

      • ArrayListIter

        public ArrayListIter​(java.util.List<O> data)
        Constructor.
        Parameters:
        data - Data array.
    • Method Detail

      • valid

        public boolean valid()
        Description copied from interface: Iter
        Returns true if the iterator currently points to a valid object.
        Specified by:
        valid in interface Iter
        Returns:
        a boolean value, whether the position is valid.
      • advance

        public ArrayListIter<O> advance()
        Description copied from interface: Iter
        Moves the iterator forward to the next entry.
        Specified by:
        advance in interface ArrayIter
        Specified by:
        advance in interface It<O>
        Specified by:
        advance in interface Iter
        Returns:
        The iterator itself.
      • getOffset

        public int getOffset()
        Description copied from interface: ArrayIter
        Get current iterator offset.
        Specified by:
        getOffset in interface ArrayIter
        Returns:
        Iterator position
      • advance

        public ArrayListIter<O> advance​(int count)
        Description copied from interface: ArrayIter
        Moves the iterator forward or backward by the given offset.
        Specified by:
        advance in interface ArrayIter
        Parameters:
        count - offset to move forward or backwards
        Returns:
        Iterator
      • retract

        public ArrayListIter<O> retract()
        Description copied from interface: ArrayIter
        Moves the iterator backward to the previous entry.
        Specified by:
        retract in interface ArrayIter
        Returns:
        Iterator
      • seek

        public ArrayListIter<O> seek​(int off)
        Description copied from interface: ArrayIter
        Moves the iterator to the given position
        Specified by:
        seek in interface ArrayIter
        Parameters:
        off - Seek offset
        Returns:
        Iterator
      • get

        public O get()
        Description copied from interface: It
        Access the current object.
        Specified by:
        get in interface It<O>
        Returns:
        Current object