# Services available for Collections

### add(set: java.util.Set, collection: java.util.Collection) = Set

Returns the concatenation of the given collection into the current set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'} + OrderedSet{'c', 'b', 'f'} | OrderedSet{'a', 'b', 'c', 'f'}

The service addAll has been replaced by "add" in order to have access to the operator "+" between to sets

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | OrderedSet{'a', 'b', 'c'}.addAll(OrderedSet{'c', 'b', 'f'}) | OrderedSet{'a', 'b', 'c', 'f'}

### add(sequence: java.util.List, collection: java.util.Collection) = List

Returns the concatenation of the given collection into the given sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}.add(Sequence{'d', 'e'}) | Sequence{'a', 'b', 'c', 'd', 'e'}
Sequence{'a', 'b', 'c'} + OrderedSet{'c', 'e'} | Sequence{'a', 'b', 'c', 'c', 'e'}

The service addAll has been replaced by "add" in order to have access to the operator "+" between to sequences

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | Sequence{'a', 'b', 'c'} + Sequence{'d', 'e'} | Sequence{'a', 'b', 'c', 'd', 'e'}
Acceleo 3 (MTL) | Sequence{'a', 'b', 'c'}.addAll(OrderedSet{'c', 'e'}) | Sequence{'a', 'b', 'c', 'c', 'e'}

### any(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Object

Gets the first element in the current collection for which the value returned by the lambda evaluates to "true".

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->any(str | str.size() = 1) | 'a'

### asOrderedSet(collection: java.util.Collection) = Set

Returns a set representation of the specified collection. Returns the same object if it is a set already. This operation has the same behavior as "asSet()"

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->asOrderedSet() | OrderedSet{'a', 'b', 'c'}
Sequence{'a', 'b', 'c'}->asOrderedSet() | OrderedSet{'a', 'b', 'c'}

### asSequence(collection: java.util.Collection) = List

Returns a sequence representation of the specified collection. Returns the same object if it is already a sequence.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->asSequence() | Sequence{'a', 'b', 'c'}
Sequence{'a', 'b', 'c'}->asSequence() | Sequence{'a', 'b', 'c'}

### asSet(collection: java.util.Collection) = Set

Returns a set representation of the specified collection. Returns the same object if it is already a set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->asSet() | OrderedSet{'a', 'b', 'c'}
Sequence{'a', 'b', 'c', 'c', 'a'}->asSet() | OrderedSet{'a', 'b', 'c'}

### at(sequence: java.util.List, position: java.lang.Integer) = Object

Returns the element at the specified position in the sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->at(1) | 'a'
Sequence{'a', 'b', 'c'}->at(2) | 'b'

### closure(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Set

Returns a set containing the result of applying "lambda" recursivly.

Expression | Result
--- | ---
Sequence{eCls}->closure(e | e.eContainer()) | Sequence{subEPkg, ePkg, rootEPkg}

### collect(sequence: java.util.List, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = List

Returns a sequence containing the result of applying "lambda" on all elements contained in the current sequence, maintaining order.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->collect(str | str.toUpper()) | Sequence{'A', 'B', 'C'}

### collect(set: java.util.Set, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Set

Returns a set containing the result of applying "lambda" on all elements contained in the current set, maintaining order.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->collect(str | str.toUpper()) | OrderedSet{'A', 'B', 'C'}

### concat(set: java.util.Set, collection: java.util.Collection) = Set

Returns the concatenation of the current set with the given collection.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}.concat(Sequence{'d', 'e'}) | OrderedSet{'a', 'b', 'c', 'd', 'e'}

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | OrderedSet{'a', 'b', 'c'}.addAll(Sequence{'d', 'e'}) | OrderedSet{'a', 'b', 'c', 'd', 'e'}

### concat(sequence: java.util.List, collection: java.util.Collection) = List

Returns the concatenation of the current sequence with the given collection.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}.concat(Sequence{'d', 'e'}) | Sequence{'a', 'b', 'c', 'd', 'e'}

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | Sequence{'a', 'b', 'c'}.addAll(Sequence{'d', 'e'}) | Sequence{'a', 'b', 'c', 'd', 'e'}

### count(set: java.util.Set, object: java.lang.Object) = Integer

Returns "1" if the current set contains the given object, "0" otherwise.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->count('d') | 0
OrderedSet{'a', 'b', 'c'}->count('a') | 1

### count(sequence: java.util.List, object: java.lang.Object) = Integer

Counts the number of occurrences of the given object in the given sequence

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->count('d') | 0
Sequence{'a', 'b', 'c'}->count('a') | 1

### excludes(collection: java.util.Collection, object: java.lang.Object) = Boolean

Indicates if the given collection doesn't contain the given object.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->excludes('a') | false
Sequence{'a', 'b', 'c'}->excludes('d') | true

### excludesAll(collection1: java.util.Collection, collection2: java.util.Collection) = Boolean

Indicates if no elements from the second collection are contained in the first collection

Expression | Result
--- | ---
Sequence{'a', 'b'}->excludesAll(OrderedSet{'f'}) | true
Sequence{'a', 'b'}->excludesAll(OrderedSet{'a', 'f'}) | false

### excluding(set: java.util.Set, object: java.lang.Object) = Set

Removes the given object from the current set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->excluding('c') | OrderedSet{'a', 'b'}

### excluding(sequence: java.util.List, object: java.lang.Object) = List

Removes the given object from the current sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->excluding('c') | Sequence{'a', 'b'}

### exists(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Boolean

Indicates if it exists an object from the given collection for which the given lambda evaluates to "true"

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->exists(str | str.size() > 5) | false

### filter(set: java.util.Set, eClassifier: org.eclipse.emf.ecore.EClassifier) = Set

Keeps only instances of the given EClassifier from the given set.

Expression | Result
--- | ---
OrderedSet{anEClass, anEAttribute, anEReference}->filter(ecore::EClass) | OrederedSet{anEClass}
OrderedSet{anEClass, anEAttribute}->filter(ecore::EStructuralFeature) | OrederedSet{anEAttribute}

### filter(sequence: java.util.List, eClassifiers: java.util.Set) = List

Keeps only instances of the given EClassifier in the given sequence.

Expression | Result
--- | ---
Sequence{anEClass, anEAttribute, anEReference}->filter({ecore::EClass | ecore::EReference}) | Sequence{anEClass, anEReference}
Sequence{anEClass, anEAttribute, anEPackage}->filter({ecore::EStructuralFeature | ecore::EPacakge}) | Sequence{anEAttribute, anEPackage}

### filter(set: java.util.Set, eClassifiers: java.util.Set) = Set

Keeps only instances of the given set of EClassifier from the given set.

Expression | Result
--- | ---
OrderedSet{anEClass, anEAttribute, anEReference}->filter({ecore::EClass | ecore::EReference}) | OrderedSet{anEClass, anEReference}
OrderedSet{anEClass, anEAttribute, anEPackage}->filter({ecore::EStructuralFeature | ecore::EPacakge}) | OrderedSet{anEAttribute, anEPackage}

### filter(sequence: java.util.List, eClassifier: org.eclipse.emf.ecore.EClassifier) = List

Keeps only instances of the given EClassifier in the given sequence.

Expression | Result
--- | ---
Sequence{anEClass, anEAttribute, anEReference}->filter(ecore::EClass) | Sequence{anEClass}
Sequence{anEClass, anEAttribute}->filter(ecore::EStructuralFeature) | Sequence{anEAttribute}

### first(collection: java.util.Collection) = Object

Returns the first element of the specified Collection.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->first() | 'a'

### forAll(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Boolean

Indicates if all the objects from the given collection validate the given lamba

Expression | Result
--- | ---
Sequence{'a', 'b', 'ccc'}->forAll(str | str.size() = 1) | false
Sequence{'a', 'b', 'c'}->forAll(str | str.size() = 1) | false

### includes(collection: java.util.Collection, object: java.lang.Object) = Boolean

Indicates if the given collection contains the given object.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->includes('a') | true
Sequence{'a', 'b', 'c'}->includes('d') | false

### includesAll(collection1: java.util.Collection, collection2: java.util.Collection) = Boolean

Indicates if all elements from the second collection are contained in the first collection

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->includesAll(OrderedSet{'a'}) | true
Sequence{'a', 'b', 'c'}->includesAll(OrderedSet{'a', 'f'}) | false

### including(sequence: java.util.List, object: java.lang.Object) = List

Adds the given object to the current sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->including('d') | Sequence{'a', 'b', 'c', 'd'}

### including(set: java.util.Set, object: java.lang.Object) = Set

Adds the given object to the current set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->including('d') | OrderedSet{'a', 'b', 'c', 'd'}

### indexOf(set: java.util.Set, object: java.lang.Object) = Integer

Returns the index of the given object in the given set ([1..size]).

Expression | Result
--- | ---
OrderedSet{1, 2, 3, 4}->indexOf(3) | 3

### indexOf(sequence: java.util.List, object: java.lang.Object) = Integer

Returns the index of the given object in the given sequence ([1..size]).

Expression | Result
--- | ---
Sequence{1, 2, 3, 4}->indexOf(3) | 3

### insertAt(set: java.util.Set, position: java.lang.Integer, object: java.lang.Object) = Set

Inserts the given object in a copy of the given set at the given position ([1..size]). If the given set already contains this object, it will be moved to the accurate position.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->insertAt(2, 'f') | Sequence{'a', 'f', 'b', 'c'}

### insertAt(sequence: java.util.List, position: java.lang.Integer, object: java.lang.Object) = List

Inserts the given object in a copy of the given sequence at the given position ([1..size]).

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->insertAt(2, 'f') | Sequence{'a', 'f', 'b', 'c'}

### intersection(set: java.util.Set, collection: java.util.Collection) = Set

Creates a set with the elements from the given set that are also present in the given collection.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->intersection(OrderedSet{'a', 'f'}) | OrderedSet{'a'}

### intersection(sequence: java.util.List, collection: java.util.Collection) = List

Creates a sequence with elements from the given sequence that are present in both the current sequence and the given other {@code Collection}. Iteration order will match that of the current sequence. Duplicates from the first list will all be kept in the result if they also are in the second one, but duplicates from the second list will be dumped even if they are present in the first.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->intersection(OrderedSet{'a', 'f'}) | Sequence{'a'}

### isEmpty(collection: java.util.Collection) = Boolean

Returns "true" when the input collection is empty.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->isEmpty() | false
Sequence{}->isEmpty() | true

### isUnique(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Boolean

Indicates if the evaluation of the given lambda gives a different value for all elements of the given collection.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->isUnique(str | str.size()) | false
Sequence{'a', 'bb', 'ccc'}->isUnique(str | str.size()) | true

### last(set: java.util.Set) = Object

Returns the last element of the given set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->last() | 'c'

### last(sequence: java.util.List) = Object

Returns the last element of the given sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->last() | 'c'

### notEmpty(collection: java.util.Collection) = Boolean

Returns "true" when the input collection is not empty.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->notEmpty() | true
Sequence{}->notEmpty() | false

### one(collection: java.util.Collection, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Boolean

Indicates if one and only one element of the given collection validates the given lambda.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->one(str | str.equals('a')) | true
Sequence{'a', 'a', 'c'}->one(str | str.equals('a')) | false

### prepend(set: java.util.Set, object: java.lang.Object) = Set

Inserts the given object in a copy of the given set at the first position. If the set already contained the given object, it is moved to the first position.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->prepend('f') | OrderedSet{'f', 'a', 'b', 'c'}

### prepend(sequence: java.util.List, object: java.lang.Object) = List

Inserts the given object in a copy of the given sequence at the first position.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->prepend('f') | Sequence{'f', 'a', 'b', 'c'}

### reject(set: java.util.Set, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Set

Reject returns a filtered version of the specified set. Only elements for which the given "lambda" evaluates to false will be present in the returned set

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->reject(str | str.equals('a')) | OrderedSet{'b', 'c'}

### reject(sequence: java.util.List, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = List

Reject returns a filtered version of the specified sequence. Only elements for which the given "lambda" evaluates to false will be present in the returned sequence

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->reject(str | str.equals('a')) | Sequence{'b', 'c'}

### reverse(set: java.util.Set) = Set

Returns the given set in reversed order.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->reverse() | OrderedSet{'c', 'b', 'a'}

### reverse(sequence: java.util.List) = List

Returns the given sequence in reversed order.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->reverse() | Sequence{'c', 'b', 'a'}

### select(set: java.util.Set, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Set

Select returns a filtered version of the specified set. Only elements for which the given "lambda" evaluates to true will be present in the returned set.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->select(str | str.equals('a')) | OrderedSet{'a'}

### select(sequence: java.util.List, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = List

Select returns a filtered version of the specified sequence. Only elements for which the given "lambda" evaluates to true will be present in the returned sequence.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->select(str | str.equals('a')) | Sequence{'a'}

### sep(collection: java.util.Collection, separator: java.lang.Object) = List

Inserts the given separator between each elements of the given collection.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->sep('-') | Sequence{'a', '-', 'b', '-', 'c'}
OrderedSet{'a', 'b', 'c'}->sep('-') | Sequence{'a', '-', 'b', '-', 'c'}

### sep(collection: java.util.Collection, prefix: java.lang.Object, separator: java.lang.Object, suffix: java.lang.Object) = List

Inserts the given separator between each elements of the given collection, the given prefix before the first element, and the given suffix after the last element.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->sep('[', '-', ']') | Sequence{'[', 'a', '-', 'b', '-', 'c', ']'}

### size(collection: java.util.Collection) = Integer

Returns the size of the specified collection

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->size() | 3
OrderedSet{'a', 'b', 'c', 'd'}->size() | 4

### sortedBy(sequence: java.util.List, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = List

Returns a sequence containing the elements of the original sequence ordered by the result of the given lamba

Expression | Result
--- | ---
Sequence{'aa', 'bbb', 'c'}->sortedBy(str | str.size()) | Sequence{'c', 'aa', 'bbb'}

### sortedBy(set: java.util.Set, lambda: org.eclipse.acceleo.query.runtime.impl.LambdaValue) = Set

Returns a set containing the elements of the original set ordered by the result of the given lamba

Expression | Result
--- | ---
OrderedSet{'aa', 'bbb', 'c'}->sortedBy(str | str.size()) | OrderedSet{'c', 'aa', 'bbb'}

### sub(set: java.util.Set, collection: java.util.Collection) = Set

Returns the difference of the current set and the given collection.

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'} - OrderedSet{'c', 'b', 'f'} | OrderedSet{'a'}

The service removeAll has been replaced by "sub" in order to have access to the operator "-" between to sets

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | OrderedSet{'a', 'b', 'c'}.removeAll(OrderedSet{'c', 'b', 'f'}) | OrderedSet{'a'}

### sub(sequence: java.util.List, collection: java.util.Collection) = List

Returns the difference of the current sequence and the given collection.

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'} - Sequence{'c', 'b', 'f'} | Sequence{'a'}
Sequence{'a', 'b', 'c'} - OrderedSet{'c', 'b', 'f'} | Sequence{'a'}

The service removeAll has been replaced by "sub" in order to have access to the operator "-" between to sequences

#### In other languages

Language | Expression | Result
--- | --- | ---
Acceleo 3 (MTL) | Sequence{'a', 'b', 'c'}.removeAll(Sequence{'c', 'b', 'f'}) | Sequence{'a'}
Acceleo 3 (MTL) | Sequence{'a', 'b', 'c'}.removeAll(OrderedSet{'c', 'b', 'f'}) | Sequence{'a'}

### subOrderedSet(set: java.util.Set, startIndex: java.lang.Integer, startIndex: java.lang.Integer) = Set

Returns a subset of the given set

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->subOrderedSet(1, 2) | OrderedSet{'a', 'b'}

### subSequence(sequence: java.util.List, startIndex: java.lang.Integer, startIndex: java.lang.Integer) = List

Returns a subset of the given sequence

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->subSequence(1, 2) | Sequence{'a', 'b'}

### sum(collection: java.util.Collection) = Number

Sums elements of the given collection if possible.

Expression | Result
--- | ---
Sequence{1, 2, 3, 4}->sum() | 10

### union(sequence1: java.util.List, sequence2: java.util.List) = List

Returns a sequence containing all the elements of the first and second sequences

Expression | Result
--- | ---
Sequence{'a', 'b', 'c'}->union(Sequence{'d', 'c'}) | Sequence{'a', 'b', 'c', 'd'}

### union(set1: java.util.Set, set2: java.util.Set) = Set

Returns a set containing all the elements of the first and second sets

Expression | Result
--- | ---
OrderedSet{'a', 'b', 'c'}->union(OrderedSet{'d', 'c'}) | OrderedSet{'a', 'b', 'c', 'd'}