order of returned items [message #19892] |
Thu, 02 February 2006 11:53 |
Eclipse User |
|
|
|
Originally posted by: info.dfm2html.com
Whenever I evaluate an expression which return an ordered collection,
like with ->select(..), can I have influence on the order of the returned
items,
e.g. to sort them after some special criterion, like it is possible in an
SQL-ORDER BY clause?
I
|
|
|
Re: order of returned items [message #19975 is a reply to message #19892] |
Thu, 02 February 2006 14:03 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Yes,
OCL Sequences respond to a sortedBy() operation.
For example,
Person.allInstances()->asSequence()->sortedBy(p | p.age)
sorts all Persons in existence in increasing order of age.
Formally, the type of the body expression of the sortedBy() iterator must
understand the < operation. In practice, this is implemented in the EMFT
OCL using the Comparable interface, meaning that numbers of all kinds and
Strings are accepted, as well as any EDataTypes that implement Comparable
(note that it is not recommended for EClasses to implement Comparable, as
this implies supporting value equality, which is discouraged).
OCL does not offer a convenient means to reverse a sequence.
HTH,
Christian
Jrg wrote:
> Whenever I evaluate an expression which return an ordered collection,
> like with ->select(..), can I have influence on the order of the returned
> items,
> e.g. to sort them after some special criterion, like it is possible in an
> SQL-ORDER BY clause?
> I
|
|
|
Re: order of returned items [message #565419 is a reply to message #19892] |
Thu, 02 February 2006 14:03 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Yes,
OCL Sequences respond to a sortedBy() operation.
For example,
Person.allInstances()->asSequence()->sortedBy(p | p.age)
sorts all Persons in existence in increasing order of age.
Formally, the type of the body expression of the sortedBy() iterator must
understand the < operation. In practice, this is implemented in the EMFT
OCL using the Comparable interface, meaning that numbers of all kinds and
Strings are accepted, as well as any EDataTypes that implement Comparable
(note that it is not recommended for EClasses to implement Comparable, as
this implies supporting value equality, which is discouraged).
OCL does not offer a convenient means to reverse a sequence.
HTH,
Christian
Jrg wrote:
> Whenever I evaluate an expression which return an ordered collection,
> like with ->select(..), can I have influence on the order of the returned
> items,
> e.g. to sort them after some special criterion, like it is possible in an
> SQL-ORDER BY clause?
> I
|
|
|
Powered by
FUDForum. Page generated in 0.02922 seconds