Bug 295814 - Preserve ordering in Element::subobjects() family of operations
Summary: Preserve ordering in Element::subobjects() family of operations
Status: NEW
Alias: None
Product: QVTo
Classification: Modeling
Component: Engine (show other bugs)
Version: 2.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Radomil Dvorak CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-22 15:29 EST by Radomil Dvorak CLA
Modified: 2013-04-04 09:22 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Radomil Dvorak CLA 2009-11-22 15:29:49 EST
Preserve the order of sub-objects in its containers in the following operations:
Element::subobjects() : Set(Element) 
Element::subobjectsOfType(OclType) : Set(Element) 
Element::subobjectsOfKind(OclType) : Set(Element) 
Element::allSubobjectsOfKind(OclType) : Set(Element) 

The current implementation give random order, caused by using java HahSet implementation.
Take into account the OCL runtime is based on java.util.HahSet being mapped to OCL Set type.

Consider subclassing java.util.HashSet and used cached initial collection to preduce the iterator  on 
sets. Making it readonly, as we can't really modify Sets in OCL should be a simplification.
Comment 1 Ed Willink CLA 2013-04-04 09:01:51 EDT
I would recommend only giving a repeatable order when some -debug execution option has been requested.
Comment 2 Ed Willink CLA 2013-04-04 09:22:10 EDT
It is tempting to just return an OrderedSet under the guise of a Set, but this won't work. See:

On Better Understanding OCL Collections
or
An OCL Ordered Set is not an OCL Set

Fabian B¨uttner, Martin Gogolla, Lars Hamann, Mirco Kuhlmann

http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&ved=0CEgQFjAD&url=http%3A%2F%2Fwww.springerlink.com%2Findex%2F98l4826172434143.pdf&ei=sX1dUYqcN4210QWj84DQBw&usg=AFQjCNFUF80OMoWByFBYQE0u2471uBw1zw&sig2=uKx2A9Juefan8Bi2W-XliQ&bvm=bv.44770516,d.d2k