Sequence(T)

Sequence(T)

A sequence is a collection where the elements are ordered. An element may be part of a sequence more than once. Sequence is itself an instance of the metatype SequenceType. A Sentence is not a subtype of Bag. The common supertype of Sentence and Bags is Collection.

conformsTo Collection(T)

Operations

=(object2 : OclSelf) : Boolean precedence: EQUALITY

True if self contains the same elements as s in the same order.

<>(object2 : OclSelf) : Boolean precedence: EQUALITY

append(object : T[?]) : Sequence(T)

The sequence of elements, consisting of all elements of self, followed by object.

at(index : Integer) : T[?] invalidating

The i-th element of sequence.

excluding(object : OclAny[?]) : Sequence(T)

The sequence containing all elements of self apart from all occurrences of object.

The order of the remaining elements is not changed.

first() : T[?] invalidating

The first element in self.

flatten(T2)() : Sequence(T2)

Redefines the Collection operation. If the element type is not a collection type, this results in the same sequence as self. If the element type is a collection type, the result is the sequence containing all the elements of all the recursively flattened elements of self. The order of the elements is partial.

including(object : T[?]) : Sequence(T)

The sequence containing all elements of self plus object added as the last element.

indexOf(obj : OclAny[?]) : Integer

The index of object obj in the ordered collection.

insertAt(index : Integer, object : T[?]) : Sequence(T) invalidating

The sequence consisting of self with object inserted at position index.

last() : T[?] invalidating

The last element in self.

prepend(object : T[?]) : Sequence(T)

The sequence consisting of object, followed by all elements in self.

reverse() : Sequence(T)

The sequence containing the same elements but with the opposite order.

selectByKind(TT)(type : Metaclass(TT)) : Sequence(TT)

selectByType(TT)(type : Metaclass(TT)) : Sequence(TT)

subSequence(lower : Integer, upper : Integer) : Sequence(T) invalidating

The sub-sequence of self starting at number lower, up to and including element number upper.

Iterations

closure(i : T | lambda : Lambda T() : OrderedSet(T)) : OrderedSet(T)

The closure of applying body transitively to every distinct element of the source collection.

collect(V)(i : T[?] | lambda : Lambda T() : V[?]) : Sequence(V)

collectNested(V)(i : T[?] | lambda : Lambda T() : V[?]) : Sequence(T)

The sequence of elements that results from applying body to every member of the source ordered collection.

reject(i : T[?] | lambda : Lambda T() : Boolean) : Sequence(T)

The subsequence of the source sequence for which body is false.

select(i : T[?] | lambda : Lambda T() : Boolean) : Sequence(T)

The subsequence of the source sequence for which body is true.

sortedBy(i : T[?] | lambda : Lambda T() : OclAny) : Sequence(T)

Results in the Sequence containing all elements of the source collection. The element for which body has the lowest value comes first, and so on. The type of the body expression must have the < operation defined. The < operation must return a Boolean value and must be transitive (i.e., if a < b and b < c then a < c).