Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » order of returned items
order of returned items [message #19892] Thu, 02 February 2006 11:53 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:order of returned items
Next Topic:[Announce] EMFT OCL 1.0.0 I200602020906 is available
Goto Forum:
  


Current Time: Mon Sep 26 10:55:57 GMT 2022

Powered by FUDForum. Page generated in 0.01414 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top