Package gnu.lists

Class SubSequence<E>

java.lang.Object
gnu.lists.AbstractSequence<E>
gnu.lists.SubSequence<E>
All Implemented Interfaces:
BoundedHashable, Consumable, Sequence<E>, Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>

public class SubSequence<E> extends AbstractSequence<E> implements Sequence<E>
A sequence consisting of a sub-range of the elements of a base sequence. The start and end positions are position triples (on the same sequence).
  • Constructor Details

    • SubSequence

      public SubSequence()
    • SubSequence

      public SubSequence(AbstractSequence<E> base, int startPos, int endPos)
    • SubSequence

      public SubSequence(AbstractSequence<E> base)
  • Method Details

    • get

      public E get(int index)
      Description copied from interface: Sequence
      See java.util.List.
      Specified by:
      get in interface List<E>
      Specified by:
      get in interface Sequence<E>
      Overrides:
      get in class AbstractSequence<E>
    • size

      public int size()
      Description copied from interface: Sequence
      See java.util.List.
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
      Specified by:
      size in interface Sequence<E>
      Overrides:
      size in class AbstractSequence<E>
    • removePosRange

      public void removePosRange(int istart, int iend)
      Description copied from class: AbstractSequence
      Remove a range where each end-point is a position in a container.
      Overrides:
      removePosRange in class AbstractSequence<E>
      Parameters:
      istart - start of range, as a poistion
      iend - end of range
    • isAfterPos

      protected boolean isAfterPos(int ipos)
      Description copied from class: AbstractSequence
      Tests whether the position has the "isAfter" property. I.e. if something is inserted at the position, will the iterator end up being after the new data?
      Overrides:
      isAfterPos in class AbstractSequence<E>
    • createPos

      public int createPos(int offset, boolean isAfter)
      Description copied from class: AbstractSequence
      Generate a position at a given index. The result is a position cookie that must be free'd with releasePos.
      Overrides:
      createPos in class AbstractSequence<E>
      Parameters:
      offset - offset from beginning of desired position
      isAfter - should the position have the isAfter property
    • createRelativePos

      public int createRelativePos(int pos, int offset, boolean isAfter)
      Overrides:
      createRelativePos in class AbstractSequence<E>
    • getIndexDifference

      protected int getIndexDifference(int ipos1, int ipos0)
      Description copied from class: AbstractSequence
      Get offset of (ipos1) relative to (ipos0).
      Overrides:
      getIndexDifference in class AbstractSequence<E>
    • releasePos

      public void releasePos(int ipos)
      Description copied from class: AbstractSequence
      Reclaim any resources used by the given position int.
      Overrides:
      releasePos in class AbstractSequence<E>
      Parameters:
      ipos - the Pos being free'd.
    • nextIndex

      protected int nextIndex(int ipos)
      Description copied from class: AbstractSequence
      Get the offset from the beginning corresponding to a position cookie.
      Overrides:
      nextIndex in class AbstractSequence<E>
    • compare

      public int compare(int ipos1, int ipos2)
      Description copied from class: AbstractSequence
      Compare two positions, and indicate their relative order.
      Overrides:
      compare in class AbstractSequence<E>
    • getPosNext

      public Object getPosNext(int ipos)
      Description copied from class: AbstractSequence
      Get the element following the specified position.
      Overrides:
      getPosNext in class AbstractSequence<E>
      Parameters:
      ipos - the specified position.
      Returns:
      the following element, or eofValue if there is none. Called by SeqPosition.getNext. FIXME Should change eof handling so return type can be E.
    • getNextKind

      public int getNextKind(int ipos)
      Overrides:
      getNextKind in class AbstractSequence<E>
    • startPos

      public int startPos()
      Overrides:
      startPos in class AbstractSequence<E>
    • endPos

      public int endPos()
      Overrides:
      endPos in class AbstractSequence<E>
    • getPosPrevious

      public Object getPosPrevious(int ipos)
      Description copied from class: AbstractSequence
      Get the element before the specified position.
      Overrides:
      getPosPrevious in class AbstractSequence<E>
      Parameters:
      ipos - the specified position.
      Returns:
      the following element, or eofValue if there is none. FIXME Should change eof handling so return type can be E.
    • subSequencePos

      protected Sequence<E> subSequencePos(int ipos0, int ipos1)
      Overrides:
      subSequencePos in class AbstractSequence<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
      Overrides:
      clear in class AbstractSequence<E>
    • finalize

      public void finalize()
      Overrides:
      finalize in class Object