Interface Sequence<T>

Type Parameters:
T - type of Sequence entries
All Superinterfaces:
Iterable<T>, SequenceKernel<T>, Standard<Sequence<T>>
All Known Implementing Classes:
Sequence1L, Sequence2L, Sequence3, SequenceSecondary

public interface Sequence<T> extends SequenceKernel<T>
SequenceKernel enhanced with secondary methods.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Concatenates ("appends") s to the end of this.
    entry(int pos)
    Reports the entry at position pos of this.
    void
    extract(int pos1, int pos2, Sequence<T> s)
    Removes the substring of this starting at position pos1 and ending at position pos2-1 and puts in it s.
    void
    Reverses ("flips") this.
    void
    insert(int pos, Sequence<T> s)
    Inserts s into this at position pos, i.e., after the pos-th entry of this; and clears s.
    replaceEntry(int pos, T x)
    Replaces the entry at position pos of this with the entry x and returns the old entry at that position.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface components.sequence.SequenceKernel

    add, length, remove

    Methods inherited from interface components.standard.Standard

    clear, newInstance, transferFrom
  • Method Details

    • entry

      T entry(int pos)
      Reports the entry at position pos of this.
      Parameters:
      pos - the position of the entry
      Returns:
      the entry at that position
      Aliases:
      reference returned by entry
      Requires:
      0 <= pos and pos < |this|
      Ensures:
      <entry> = this[pos, pos+1)
    • replaceEntry

      T replaceEntry(int pos, T x)
      Replaces the entry at position pos of this with the entry x and returns the old entry at that position.
      Parameters:
      pos - the position at which to replace an entry
      x - the entry replacing the old one
      Returns:
      the old entry at that position
      Aliases:
      reference x
      Updates:
      this
      Requires:
      0 <= pos and pos < |this|
      Ensures:
      <replaceEntry> = #this[pos, pos+1)  and
      this = #this[0, pos) * <x> * #this[pos+1, |#this|)
      
    • append

      void append(Sequence<T> s)
      Concatenates ("appends") s to the end of this.
      Parameters:
      s - the Sequence to be appended
      Updates:
      this
      Clears:
      s
      Ensures:
      this = #this * #s
    • flip

      void flip()
      Reverses ("flips") this.
      Updates:
      this
      Ensures:
      this = rev(#this)
    • insert

      void insert(int pos, Sequence<T> s)
      Inserts s into this at position pos, i.e., after the pos-th entry of this; and clears s.
      Parameters:
      pos - the position at which to insert
      s - the Sequence to be inserted
      Updates:
      this
      Clears:
      s
      Requires:
      0 <= pos and pos <= |this|
      Ensures:
      this = #this[0, pos) * #s * #this[pos, |#this|)
    • extract

      void extract(int pos1, int pos2, Sequence<T> s)
      Removes the substring of this starting at position pos1 and ending at position pos2-1 and puts in it s.
      Parameters:
      pos1 - the position of the first entry that is extracted
      pos2 - the position of the first entry, after the extracted substring, that is not extracted
      s - upon return, the extracted substring
      Updates:
      this
      Replaces:
      s
      Requires:
      0 <= pos1 and pos1 <= pos2 and pos2 <= |this|
      Ensures:
      this = #this[0, pos1) * #this[pos2, |#this|)  and
      s = #this[pos1, pos2)