Category
OCL Collection Operators
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
|Returns a Bag containing all elements of ''self''. | |Returns a Bag containing all elements of ''self''. | ||
|- | |- | ||
|'''[[OCLOperators asSequence|->asSequence]]''' | |'''[[Documentation:OCLOperators asSequence|->asSequence]]''' | ||
|Returns a Sequence containing all elements of ''self''. Element ordering is preserved when possible. | |Returns a Sequence containing all elements of ''self''. Element ordering is preserved when possible. | ||
|- | |- | ||
|'''[[OCLOperators asSet|->asSet]]''' | |'''[[Documentation:OCLOperators asSet|->asSet]]''' | ||
|Returns a Set containing all elements of ''self''. | |Returns a Set containing all elements of ''self''. | ||
|- | |- | ||
|'''[[OCLOperators at|->at]]''' | |'''[[Documentation:OCLOperators at|->at]]''' | ||
|Get the objects at X where the first index is 1 | |Get the objects at X where the first index is 1 | ||
|- | |- | ||
|'''[[OCLOperators at0|->at0]]''' | |'''[[Documentation:OCLOperators at0|->at0]]''' | ||
|Get the objects at X where the first index is 0 | |Get the objects at X where the first index is 0 | ||
|- | |- | ||
|'''[[OCLOperators collect|->collect]]''' | |'''[[Documentation:OCLOperators collect|->collect]]''' | ||
|Returns a collection containing the result of applying ''expr'' on all elements contained in ''self''. | |Returns a collection containing the result of applying ''expr'' on all elements contained in ''self''. | ||
|- | |- | ||
|'''[[OCLOperators count|->count]]''' | |'''[[Documentation:OCLOperators count|->count]]''' | ||
|Count how many meet a certain criteria | |Count how many meet a certain criteria | ||
|- | |- | ||
|[[OCLOperators dictionary| | |'''[[Documentation:OCLOperators dictionary|->dictionary]]''' | ||
|Efficiently looks up values | |Efficiently looks up values | ||
|- | |- | ||
|'''[[OCLOperators difference|->difference]]''' | |'''[[Documentation:OCLOperators difference|->difference]]''' | ||
|The difference between 2 collections | |The difference between 2 collections | ||
|- | |- | ||
|'''[[OCLOperators excluding|->excluding]]''' | |'''[[Documentation:OCLOperators excluding|->excluding]]''' | ||
|The collection except for this single object | |The collection except for this single object | ||
|- | |- | ||
|'''[[OCLOperators exists|->exists]]''' | |'''[[Documentation:OCLOperators exists|->exists]]''' | ||
|Returns true if at least one element in ''self'' validates the condition ''expr'', false otherwise. | |Returns true if at least one element in ''self'' validates the condition ''expr'', false otherwise. | ||
|- | |- | ||
|'''[[OCLOperators filterOnType|->filterOnType]]''' | |'''[[Documentation:OCLOperators filterOnType|->filterOnType]]''' | ||
|Only keep the ones of a certain type | |Only keep the ones of a certain type | ||
|- | |- | ||
|'''[[OCLOperators first|->first]]''' | |'''[[Documentation:OCLOperators first|->first]]''' | ||
|Return the first object | |Return the first object | ||
|- | |- | ||
|'''[[OCLOperators forAll|->forAll]]''' | |'''[[Documentation:OCLOperators forAll|->forAll]]''' | ||
|Returns true if all the elements contained in ''self'' validate the condition ''expr'', false otherwise. | |Returns true if all the elements contained in ''self'' validate the condition ''expr'', false otherwise. | ||
|- | |- | ||
|'''[[OCLOperators groupBy|->groupBy]]''' | |'''[[Documentation:OCLOperators groupBy|->groupBy]]''' | ||
|Build a collection of tuples grouped by some aspect | |Build a collection of tuples grouped by some aspect | ||
|- | |- | ||
|'''[[OCLOperators includes|->includes]]''' | |'''[[Documentation:OCLOperators includes|->includes]]''' | ||
|Does the collection include the object | |Does the collection include the object | ||
|- | |- | ||
|'''[[OCLOperators includesAll|->includesAll]]''' | |'''[[Documentation:OCLOperators includesAll|->includesAll]]''' | ||
|Does the collection include the whole other collection | |Does the collection include the whole other collection | ||
|- | |- | ||
|'''[[OCLOperators including|->including]]''' | |'''[[Documentation:OCLOperators including|->including]]''' | ||
|Returns the list with the element in the parameter included. | |Returns the list with the element in the parameter included. | ||
|- | |- | ||
|'''[[OCLOperators indexOf|->IndexOf]]''' | |'''[[Documentation:OCLOperators indexOf|->IndexOf]]''' | ||
|The 1 based index of an object in the collection possibly -1 if not existing | |The 1 based index of an object in the collection possibly -1 if not existing | ||
|- | |- | ||
|'''[[OCLOperators indexOf0|->indexOf0]]''' | |'''[[Documentation:OCLOperators indexOf0|->indexOf0]]''' | ||
|The 0 based index of an object in the collection possibly -1 if not existing | |The 0 based index of an object in the collection possibly -1 if not existing | ||
|- | |- | ||
|'''[[OCLOperators intersection|->intersection]]''' | |'''[[Documentation:OCLOperators intersection|->intersection]]''' | ||
|The intersection of two collections | |The intersection of two collections | ||
|- | |- | ||
|'''[[OCLOperators isEmpty|->isEmpty]]''' | |'''[[Documentation:OCLOperators isEmpty|->isEmpty]]''' | ||
|Returns true if the collection is empty | |Returns true if the collection is empty | ||
|- | |- | ||
|'''[[OCLOperators notEmpty|->]][[OCLOperators notEmpty|notEmpty]]''' | |'''[[OCLOperators notEmpty|->]][[Documentation:OCLOperators notEmpty|notEmpty]]''' | ||
|Returns true if ''self'' contains at least one element, false otherwise. | |Returns true if ''self'' contains at least one element, false otherwise. | ||
|- | |- | ||
|'''[[OCLOperators reject|->]][[OCLOperators reject|reject]]''' | |'''[[OCLOperators reject|->]][[Documentation:OCLOperators reject|reject]]''' | ||
|Returns a collection with all elements of ''self'' except for those who validate the OclExpression ''expr''. | |Returns a collection with all elements of ''self'' except for those who validate the OclExpression ''expr''. | ||
|- | |- | ||
|'''[[OCLOperators select|->]][[OCLOperators select|select]]''' | |'''[[OCLOperators select|->]][[Documentation:OCLOperators select|select]]''' | ||
|Returns a collection with all elements of ''self'' that validate the OclExpression ''expr''. | |Returns a collection with all elements of ''self'' that validate the OclExpression ''expr''. | ||
|- | |- | ||
|'''[[OCLOperators size|->]][[OCLOperators size|size]]''' | |'''[[OCLOperators size|->]][[Documentation:OCLOperators size|size]]''' | ||
|Returns the number of elements contained in ''self''. | |Returns the number of elements contained in ''self''. | ||
|- | |- | ||
|'''[[OCLOperators sum|->]][[OCLOperators sum|sum]]''' | |'''[[OCLOperators sum|->]][[Documentation:OCLOperators sum|sum]]''' | ||
|Returns the sum of all elements contained in ''self'' if they support the '+' operation. | |Returns the sum of all elements contained in ''self'' if they support the '+' operation. | ||
|- | |- | ||
|'''[[OCLOperators last|->last]]''' | |'''[[Documentation:OCLOperators last|->last]]''' | ||
|Returns the last object in the collection | |Returns the last object in the collection | ||
|- | |- | ||
|'''[[OCLOperators orderBy|->orderBy]]''' | |'''[[Documentation:OCLOperators orderBy|->orderBy]]''' | ||
|Sorts the collection on one or more properties | |Sorts the collection on one or more properties | ||
|- | |- | ||
|'''[[OCLOperators orderDescending|->orderDescending]]''' | |'''[[Documentation:OCLOperators orderDescending|->orderDescending]]''' | ||
|Sort the from biggest to smallest | |Sort the from biggest to smallest | ||
|- | |- | ||
|'''[[OCLOperators orderGeneric|->orderGeneric]]''' | |'''[[Documentation:OCLOperators orderGeneric|->orderGeneric]]''' | ||
|Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) | |Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) | ||
|- | |- | ||
|'''[[OCLOperators prepend|->prepend]]''' | |'''[[Documentation:OCLOperators prepend|->prepend]]''' | ||
|Returns an OrderedSet containing ''object'' followed by all elements of ''self''. | |Returns an OrderedSet containing ''object'' followed by all elements of ''self''. | ||
|- | |- | ||
|'''[[OCLOperators subSequence|->subsequence]]''' | |'''[[Documentation:OCLOperators subSequence|->subsequence]]''' | ||
|Returns a smaller collection from a start to stop | |Returns a smaller collection from a start to stop | ||
|- | |- | ||
|'''[[OCLOperators symmetricDifference|->symmetricDifference]]''' | |'''[[Documentation:OCLOperators symmetricDifference|->symmetricDifference]]''' | ||
|The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both | |The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both | ||
|- | |- | ||
|'''[[OCLOperators union|->union]]''' | |'''[[Documentation:OCLOperators union|->union]]''' | ||
|The set of objects in collection1 and objects in collection2 | |The set of objects in collection1 and objects in collection2 | ||
|} | |} | ||
Line 119: | Line 119: | ||
See this page for [[Documentation:Examples on collection operators|examples on collection operators.]] | See this page for [[Documentation:Examples on collection operators|examples on collection operators.]] | ||
Also check out: [[Documentation:OCLOperators|OCLOperators]] | '''Also check out:''' [[Documentation:OCLOperators|OCLOperators]] |
Revision as of 05:39, 10 February 2025
This page was created by Stephanie@mdriven.net on 2023-04-12. Last edited by Stephanie@mdriven.net on 2025-03-10.
Once you have a collection of objects, there are certain operators applicable to them.
You can use the OCL-Editor to see what they are:
Operators | Description |
---|---|
->append | Add another object last |
->asBag | Returns a Bag containing all elements of self. |
->asSequence | Returns a Sequence containing all elements of self. Element ordering is preserved when possible. |
->asSet | Returns a Set containing all elements of self. |
->at | Get the objects at X where the first index is 1 |
->at0 | Get the objects at X where the first index is 0 |
->collect | Returns a collection containing the result of applying expr on all elements contained in self. |
->count | Count how many meet a certain criteria |
->dictionary | Efficiently looks up values |
->difference | The difference between 2 collections |
->excluding | The collection except for this single object |
->exists | Returns true if at least one element in self validates the condition expr, false otherwise. |
->filterOnType | Only keep the ones of a certain type |
->first | Return the first object |
->forAll | Returns true if all the elements contained in self validate the condition expr, false otherwise. |
->groupBy | Build a collection of tuples grouped by some aspect |
->includes | Does the collection include the object |
->includesAll | Does the collection include the whole other collection |
->including | Returns the list with the element in the parameter included. |
->IndexOf | The 1 based index of an object in the collection possibly -1 if not existing |
->indexOf0 | The 0 based index of an object in the collection possibly -1 if not existing |
->intersection | The intersection of two collections |
->isEmpty | Returns true if the collection is empty |
->notEmpty | Returns true if self contains at least one element, false otherwise. |
->reject | Returns a collection with all elements of self except for those who validate the OclExpression expr. |
->select | Returns a collection with all elements of self that validate the OclExpression expr. |
->size | Returns the number of elements contained in self. |
->sum | Returns the sum of all elements contained in self if they support the '+' operation. |
->last | Returns the last object in the collection |
->orderBy | Sorts the collection on one or more properties |
->orderDescending | Sort the from biggest to smallest |
->orderGeneric | Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...) |
->prepend | Returns an OrderedSet containing object followed by all elements of self. |
->subsequence | Returns a smaller collection from a start to stop |
->symmetricDifference | The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both |
->union | The set of objects in collection1 and objects in collection2 |
See this page for examples on collection operators.
Also check out: OCLOperators
Pages in category "OCL Collection Operators"
The following 41 pages are in this category, out of 41 total.
O
- Documentation:OCL Operators product
- Documentation:OCLOperators append
- Documentation:OCLOperators asBag
- Documentation:OCLOperators asSequence
- Documentation:OCLOperators asSet
- Documentation:OCLOperators at
- Documentation:OCLOperators at0
- Documentation:OCLOperators collect
- Documentation:OCLOperators collectNested
- Documentation:OCLOperators count
- Documentation:OCLOperators dictionary
- Documentation:OCLOperators difference
- Documentation:OCLOperators excluding
- Documentation:OCLOperators exists
- Documentation:OCLOperators filterOnType
- Documentation:OCLOperators first
- Documentation:OCLOperators forAll
- Documentation:OCLOperators foreach
- Documentation:OCLOperators groupBy
- Documentation:OCLOperators includes
- Documentation:OCLOperators includesAll
- Documentation:OCLOperators including
- Documentation:OCLOperators indexOf
- Documentation:OCLOperators indexOf0
- Documentation:OCLOperators insertAt
- Documentation:OCLOperators intersection
- Documentation:OCLOperators isEmpty
- Documentation:OCLOperators last
- Documentation:OCLOperators notEmpty
- Documentation:OCLOperators orderBy
- Documentation:OCLOperators orderDescending
- Documentation:OCLOperators orderGeneric
- Documentation:OCLOperators prepend
- Documentation:OCLOperators reject
- Documentation:OCLOperators select
- Documentation:OCLOperators size
- Documentation:OCLOperators subSequence
- Documentation:OCLOperators sum
- Documentation:OCLOperators symmetricDifference
- Documentation:OCLOperators union