OCL Collection Operators
No edit summary
(Replaced content with "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: frameless|453x453px|link=https://wiki.mdriven.net/index.php/File:Collection_of_objects_operators.png See this page for examples on collection operators. '''Also check out:''' OCLOperators")
Tags: Replaced 2017 source edit
 
(5 intermediate revisions by the same user not shown)
Line 4: Line 4:


[[File:Collection of objects operators.png|frameless|453x453px|link=https://wiki.mdriven.net/index.php/File:Collection_of_objects_operators.png]]
[[File:Collection of objects operators.png|frameless|453x453px|link=https://wiki.mdriven.net/index.php/File:Collection_of_objects_operators.png]]
{| class="wikitable"
!Operators
!Description
|-
|'''[[OCLOperators append|->append]]'''
|Add another object last
|-
|'''[[OCLOperators asBag|->asBag]]'''
|Returns a Bag containing all elements of ''self''.
|-
|'''[[OCLOperators asSequence|->asSequence]]'''
|Returns a Sequence containing all elements of ''self''. Element ordering is preserved when possible.
|-
|'''[[OCLOperators asSet|->asSet]]'''
|Returns a Set containing all elements of ''self''.
|-
|'''[[OCLOperators at|->at]]'''
|Get the objects at X where the first index is 1
|-
|'''[[OCLOperators at0|->at0]]'''
|Get the objects at X where the first index is 0
|-
|'''[[OCLOperators collect|->collect]]'''
|Returns a collection containing the result of applying ''expr'' on all elements contained in ''self''.
|-
|'''[[OCLOperators count|->count]]'''
|Count how many meet a certain criteria
|-
|[[OCLOperators dictionary|'''->dictionary''']]
|Efficiently looks up values
|-
|'''[[OCLOperators difference|->difference]]'''
|The difference between 2 collections
|-
|'''[[OCLOperators excluding|->excluding]]'''
|The collection except for this single object
|-
|'''[[OCLOperators exists|->exists]]'''
|Returns true if at least one element in ''self'' validates the condition ''expr'', false otherwise.
|-
|'''[[OCLOperators filterOnType|->filterOnType]]'''
|Only keep the ones of a certain type
|-
|'''[[OCLOperators first|->first]]'''
|Return the first object
|-
|'''[[OCLOperators forAll|->forAll]]'''
|Returns true if all the elements contained in ''self'' validate the condition ''expr'', false otherwise.
|-
|'''[[OCLOperators groupBy|->groupBy]]'''
|Build a collection of tuples grouped by some aspect
|-
|'''[[OCLOperators includes|->includes]]'''
|Does the collection include the object
|-
|'''[[OCLOperators includesAll|->includesAll]]'''
|Does the collection include the whole other collection
|-
|'''[[OCLOperators including|->including]]'''
|Returns the list with the element in the parameter included.
|-
|'''[[OCLOperators indexOf|->IndexOf]]'''
|The 1 based index of an object in the collection possibly -1 if not existing
|-
|'''[[OCLOperators indexOf0|->indexOf0]]'''
|The 0 based index of an object in the collection possibly -1 if not existing
|-
|'''[[OCLOperators intersection|->intersection]]'''
|The intersection of two collections
|-
|'''[[OCLOperators isEmpty|->isEmpty]]'''
|Returns true if the collection is empty
|-
|'''[[OCLOperators notEmpty|->]][[OCLOperators notEmpty|notEmpty]]'''
|Returns true if ''self'' contains at least one element, false otherwise.
|-
|'''[[OCLOperators reject|->]][[OCLOperators reject|reject]]'''
|Returns a collection with all elements of ''self'' except for those who validate the OclExpression ''expr''.
|-
|'''[[OCLOperators select|->]][[OCLOperators select|select]]'''
|Returns a collection with all elements of ''self'' that validate the OclExpression ''expr''.
|-
|'''[[OCLOperators size|->]][[OCLOperators size|size]]'''
|Returns the number of elements contained in ''self''.
|-
|'''[[OCLOperators sum|->]][[OCLOperators sum|sum]]'''
|Returns the sum of all elements contained in ''self'' if they support the '+' operation.
|-
|'''[[OCLOperators last|->last]]'''
|Returns the last object in the collection
|-
|'''[[OCLOperators orderBy|->orderBy]]'''
|Sorts the collection on one or more properties
|-
|'''[[OCLOperators orderDescending|->orderDescending]]'''
|Sort the from biggest to smallest
|-
|'''[[OCLOperators orderGeneric|->orderGeneric]]'''
|Sorts the list of properties with interchangeable sort order: (expr1, OclSortDirection::ascending, expr2, OclSortDirection::descending...)
|-
|'''[[OCLOperators prepend|->prepend]]'''
|Returns an OrderedSet containing ''object'' followed by all elements of ''self''.
|-
|'''[[OCLOperators subSequence|->subsequence]]'''
|Returns a smaller collection from a start to stop
|-
|'''[[OCLOperators symmetricDifference|->symmetricDifference]]'''
|The symmetric difference between the collections; ie all the objects in collection1 or collection2 but not in both
|-
|'''[[OCLOperators union|->union]]'''
|The set of objects in collection1 and objects in collection2
|}


See this page for [[examples on collection operators|examples on collection operators.]]
See this page for [[Documentation:Examples on collection operators|examples on collection operators.]]


Also check out: https://wiki.mdriven.net/index.php/OCLOperators
'''Also check out:''' [[Documentation:OCLOperators|OCLOperators]]

Latest revision as of 05:00, 10 March 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:

Collection of objects operators.png

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.