Package gnu.lists

Class SubSequence<E>

  • All Implemented Interfaces:
    BoundedHashable, Consumable, Sequence<E>, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<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 Detail

      • SubSequence

        public SubSequence()
      • SubSequence

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

      • get

        public E get​(int index)
        Description copied from interface: Sequence
        See java.util.List.
        Specified by:
        get in interface java.util.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 java.util.Collection<E>
        Specified by:
        size in interface java.util.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
      • 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 java.lang.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.
      • getPosPrevious

        public java.lang.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.
      • clear

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

        public void finalize()
        Overrides:
        finalize in class java.lang.Object