Interface SymbolicSequence<T extends SymbolicExpression>

Type Parameters:
T - the element type
All Superinterfaces:
Iterable<T>, SymbolicObject

public interface SymbolicSequence<T extends SymbolicExpression> extends SymbolicObject, Iterable<T>
A finite ordered immutable sequence of symbolic expressions.
  • Method Details

    • size

      int size()
      Returns the number of elements in this sequence.
      Returns:
      the number of elements in this sequence
    • getFirst

      T getFirst()
      Returns the "first" element of this collection or null if the collection is empty. For ordered collections, first means what you expect; for unordered collections it is some fixed element.
      Returns:
      the first element.
    • get

      T get(int index)
      Gets the index-th element of this sequence
      Returns:
      the index-th element of this sequence
      Throws:
      RuntimeException - if index is negative or greater than or equal to the size
    • add

      SymbolicSequence<T> add(T element)
      Appends an element to the end of a sequence.
      Parameters:
      element - a symbolic expression
      Returns:
      a sequence identical to the given one except with the given element added to the end
    • set

      SymbolicSequence<T> set(int index, T element)
      "Sets" the element at specified position, or, more precisely, returns a new sequence identical to this except with the element at the specified index set to the given element. Sequence must have length at least index+1.
      Parameters:
      index - integer in range [0,n-1], where n is length of sequence
      element - a symbolic expression
      Returns:
      a sequence identical to this except that element in position index now has value element
    • remove

      SymbolicSequence<T> remove(int index)
      "Removes" the element at position index, shifting all subsequent elements down one; more precisely, returns a new sequence obtained by removing that element from this sequence.
      Parameters:
      index - integer in range [0,n-1], where n is length of sequence
      Returns:
      a sequence obtained from given one by removing the element and shifting remaining element down one in index
    • insert

      SymbolicSequence<T> insert(int index, T element)
      Inserts element at position index, shifting all subsequence elements up one.
      Parameters:
      index - integer in range [0,n], where n is length of sequence. If index is n, this is equivalent to appending the element to the end of the sequence
      element - the element to insert into the sequence
      Returns:
      a sequence obtained from given one by inserting the element at the specified index
    • setExtend

      SymbolicSequence<T> setExtend(int index, T value, T filler)
      If index is less than the original size s, same as set. Otherwise returns a sequence of length index+1, with the elements in positions s, s+1, ..., index-1 set to filler, and the element in position index set to value, and all other elements as in the original.
      Parameters:
      index - position to set
      value - new value for element at position
      filler - element to be inserted in newly created empty slots
      Returns:
      a new sequence, possibly extended with filler, in which element at position index is value
    • subSequence

      SymbolicSequence<T> subSequence(int start, int end)
      Returns the subsequence whose first element is the element at position start and last element is the element at position end-1. The length of the subsequence is therefore end-start.
      Parameters:
      start - index of first element
      end - one more than then index of last element
      Returns:
      the subsequence
    • apply

      <U extends SymbolicExpression> SymbolicSequence<U> apply(Transform<T,U> transform)
      Returns a sequence obtained by applying a function to every element of this sequence; also known as "map".
      Type Parameters:
      U - target type of transformation
      Parameters:
      transform - a function from T to U
      Returns:
      a sequence of same length as this one obtained by applying transform to each element
    • getNumNull

      int getNumNull()
      Returns the number of "NULL" elements of this sequence, i.e., symbolic expressions for which method SymbolicExpression.isNull() returns true.
      Returns:
      number of NULL symbolic expressions in this sequence