Module dev.civl.sarl
Package dev.civl.sarl.IF.object
Interface SymbolicSequence<T extends SymbolicExpression>
- Type Parameters:
T- the element type
- All Superinterfaces:
Iterable<T>,SymbolicObject
A finite ordered immutable sequence of symbolic expressions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.civl.sarl.IF.object.SymbolicObject
SymbolicObject.SymbolicObjectKind -
Method Summary
Modifier and TypeMethodDescriptionAppends an element to the end of a sequence.<U extends SymbolicExpression>
SymbolicSequence<U> Returns a sequence obtained by applying a function to every element of this sequence; also known as "map".get(int index) Gets theindex-th element of this sequencegetFirst()Returns the "first" element of this collection or null if the collection is empty.intReturns the number of "NULL" elements of this sequence, i.e., symbolic expressions for which methodSymbolicExpression.isNull()returnstrue.Inserts element at position index, shifting all subsequence elements up one.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."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.If index is less than the original size s, same as set.intsize()Returns the number of elements in this sequence.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.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface dev.civl.sarl.IF.object.SymbolicObject
containsQuantifier, containsSubobject, containsSubobjectIgnoringType, equals, getOrder, hashCode, id, isCanonic, setInCanonic, setOrder, symbolicObjectKind, toString, toStringBuffer, toStringBufferLong
-
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
Gets theindex-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
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
"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 sequenceelement- a symbolic expression- Returns:
- a sequence identical to this except that element in position
indexnow has valueelement
-
remove
"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
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 sequenceelement- the element to insert into the sequence- Returns:
- a sequence obtained from given one by inserting the element at the specified index
-
setExtend
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 setvalue- new value for element at positionfiller- 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
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 elementend- one more than then index of last element- Returns:
- the subsequence
-
apply
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 fromTtoU- Returns:
- a sequence of same length as this one obtained by applying
transformto each element
-
getNumNull
int getNumNull()Returns the number of "NULL" elements of this sequence, i.e., symbolic expressions for which methodSymbolicExpression.isNull()returnstrue.- Returns:
- number of NULL symbolic expressions in this sequence
-