Collection is the root abstract class for all kermeta collections
@CompilerIgnore "true"
@ScalaCompilerName "k2.standard.Collection"
Method Summary | |
---|---|
Void |
add()
|
Void |
addAll[T](Collection)
|
Void |
addSafe(Object)
|
|
any()
|
Bag[G] |
asBag()
|
OrderedSet[G] |
asOrderedSet()
|
Sequence[G] |
asSequence()
|
Sequence[Y] |
asSequenceType[Y]()
|
Set[G] |
asSet()
|
Void |
clear()
|
Sequence[T] |
collect[T]()
|
Boolean |
contains()
|
Boolean |
containsAll(Collection)
|
Integer |
count()
|
|
detect()
|
Void |
each()
|
Boolean |
empty()
|
Boolean |
excludes()
|
Boolean |
excludesAll(Collection)
|
Boolean |
exists()
|
Boolean |
existsCpl()
|
Boolean |
forAll()
|
Boolean |
forAllCpl()
|
Boolean |
includes()
|
Boolean |
includesAll(Collection)
|
Void |
indexedEach()
|
Boolean |
isEmpty()
|
Boolean |
isNotEmpty()
|
Boolean |
isUnique[T]()
|
Iterator[G] |
iterator()
|
|
one()
|
Sequence[G] |
reject()
|
Void |
remove()
|
Sequence[G] |
select()
|
Sequence[G] |
selectOne()
|
Integer |
size()
|
|
sum()
|
Void add[()
Adds an element in the Collection (default implementation)
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;951;994"
Void addAll[T](Collection)
Adds all elements from the Collection elements in the current Collection Standard implementation relies on Collection[G].add(G)
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;1561;1627"
Void addSafe[(Object)
Adds an element in the Collection if it is of compatible with the collection content
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;1098;1150"
any[()
Returns an element from the Collection Raises an EmptyCollection exception if the Collection is empty
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;4050;4080"
Bag[G] asBag[()
Returns a new Bag built from the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9470;9507"
OrderedSet[G] asOrderedSet[()
Returns a new OrderedSet built from the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9960;10011"
Sequence[G] asSequence[()
Returns a new Sequence built from the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;10078;10125"
Sequence[Y] asSequenceType[Y]()
Returns a new Sequence built from the Collection and filtering only the elements of type Y This is a more efficient version of e.select{ elem | elem.isInstanceOf(Y) }.collect{elem | elem.asType(Y) }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9834;9891"
Set[G] asSet[()
Returns a new Set built from the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9570;9607"
Void clear[()
Removes all elements from the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;1374;1410"
Sequence[T] collect[T]()
Returns a new Sequence which content corresponds to the result of running the collector function for each element of the Collection The new collection size is the same as in the original collection, and which element types is the type of the result of the expression. example : aCollection2 := aCollection.collect { e | \/* put here an expression, for example e.name *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;7042;7111"
Boolean contains[()
Returns a Boolean stating whether the Collection contains at least one instance of element, based on G.equals(elt : Object) definition Note: for checking whether a physical element is contained by the collection, make use of G.oid()
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;1891;1944"
Boolean containsAll[(Collection)
Returns true if current Collection contains at least one instance of each element of Collection elements See Collection[G].contains(G) Standard implementation relies on Collection[G].contains(G)
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;2389;2457"
Integer count[()
Returns the number of instances of element in the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9160;9209"
detect[()
Returns an element of the Collection (usually the first) for which the detector function is true Returns void if no elements is validated by the detector function example : anObject := aCollection.detect { e | \/* a condition *\/} // returns an element that fulfill the condition.
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;7791;7850"
Void each[()
Runs function func on each element of the Collection. Each is safe against concurrent modifications: even if the collection is modified by the function func, the iteration will procede on the original collection safely. Example : aCollection.each { e | \/* do something with each element e of this collection *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;4436;4490"
Boolean empty[()
Returns a Boolean stating whether the Collection is empty
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3208;3246"
Boolean excludes[()
Returns true if the Collection does not contain element
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;2766;2818"
Boolean excludesAll[(Collection)
Returns true if the Collection contains no element of Collection elements Standard implementation relies on excludes
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;2958;3026"
Boolean exists[()
Returns a Boolean stating whether at least one element of the Collection validates the condition specified by function func example : aBoolean := aCollection.exists { e | \/* a condition *\/} // returns true if at least one element fulfill the condition.
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;6370;6435"
Boolean existsCpl[()
Combinaison of exists on two elements in the collection result := self.exists{x | self.exists {y | f(x,y)}}
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;6566;6633"
Boolean forAll[()
Returns a Boolean stating whether no element of the Collection invalidates the condition specified by function func example : aBoolean := aCollection.forAll { e | \/* put here a condition *\/ } // return true if the condition is true for all elements in the collection.
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;5676;5736"
Boolean forAllCpl[()
Combinaison of ForAll on two elements in the collection result := self.forAll{x | self.forAll {y | f(x,y)}} (where x and y are 2 elements of the Collection) typical use sample : ownedState.forAllCpl{s1,s2| (s1.name==s2.name).implies(s1==s2)}
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;6014;6081"
Boolean includes[()
OCL API alignment, does the same as contains See Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;2111;2162".contains(Object) Standard implementation relies on Collection[G].contains(G)
Boolean includesAll[(Collection)
OCL API alignment, does the same as containsAll See Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;2623;2691".containsAll(Collection[G]) Standard implementation relies on containsAll
Void indexedEach[()
Runs function func on each element of the Collection. The EachContext variable contains informations about the process that can be used in the function func. The iteration order is guaranteed only for ordered collections. IndexedEach is safe against concurrent modifications: even if the collection is modified by the lambda func, the iteration will procede on the original collection safely. Typical use: aCollection.indexedEach { e, eachContext | stdio.write("element "+ eachContext.index.toString + ": " + e.toString) if(!eachContext.isLast) then stdio.writeln(",") end } This example prints every element of the collection with its rank and adds a comma at the end of the line only if it is relevant. See also EachContext.
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;5297;5374"
Boolean isEmpty[()
OCL alignment API, does the same as empty See Collection[G].empty() Standard implementation relies on Collection[G].empty())
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3398;3438"
Boolean isNotEmpty[()
OCL alignment API Returns a Boolean stating whether the Collection contains at least one element See also Collection[G].empty() Standard implementation relies on Collection[G].empty()
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3658;3701"
Boolean isUnique[T]()
Returns a Boolean stating whether the collector function evaluates to a different value for each element of the Collection example : aCollection2 := aCollection.isUnique { e | \/* put here an expression that must be unique for all elements, for example e.name *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;7408;7474"
Iterator[G] iterator[()
Returns an Iterator on the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3758;3803"
one[()
Returns an element from the Collection or void if the Collection is empty
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3896;3926"
Sequence[G] reject[()
Returns a new Sequence composed of elements of the Collection that do not validate the rejector function example : aCollection2 := aCollection.reject { e | \/* put here a condition that returns true for elements that must be exclude in the resulting Collection *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9011;9080"
Void remove[()
Removes all instances of element from the Collection, based on G.equals(Object) definition
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;1264;1314"
Sequence[G] select[()
Returns a new Sequence composed of elements of the Collection that validate the selector function example : aCollection2 := aCollection.select { e | \/* put here a condition that returns true for elements that must be included in the resulting Collection *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;8159;8228"
Sequence[G] selectOne[()
Returns a new Sequence containing one element of the Collection that validates the selector function or an empty Sequence if no element validates the selector function example : aCollection2 := aCollection.selectOne { e | \/* put here a condition that returns true for the element that must be included in the resulting Collection *\/ }
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;8618;8693"
Integer size[()
Returns the number of elements in the Collection
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;3094;3131"
sum[()
Sum the elements of the collection if they are summable (ie implement '+' operator by inheriting of the class Summable). Returns void otherwise.
@traceability_text_reference "file:/mnt/extradisk/builds/workspace/org.kermeta.language.library_master/org/kermeta/language/org.kermeta.language.library.standard/src/main/kmt/kermeta/standard/collections.kmt;9377;9406"