Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] How to find specific object in a list(Beginner question)
[QVTo] How to find specific object in a list [message #662052] Tue, 29 March 2011 06:34 Go to next message
Amine is currently offline Amine
Messages: 2
Registered: July 2009
Junior Member
Hi,

I'm a new user of QVTo, I'm asking how can I have an iterator on a collection and search for specific objects (with '=' condition).
I want to use the index of the searched object in my collection (an OrdredSet) and do some mappings with elements just before/after it in the collection.

Something like this :
var aList := A->asOrderedSet();
var obj := --some instance 
--  have some iterator 'iter' in A
if ( obj = iter) {
   getIndex(iter)
   -- use A.get(iter+1)
}


Thanks in advance

Amine
Re: [QVTo] How to find specific object in a list [message #662065 is a reply to message #662052] Tue, 29 March 2011 06:56 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4057
Registered: July 2009
Senior Member
Hi Amine

Use the at(index) operation (indexes count from 1).

OrderedSets have not always had all the operations you might expect so
you might need to ->asSequence() first.

Regards

Ed Willink

On 29/03/2011 07:34, Amine wrote:
> Hi,
>
> I'm a new user of QVTo, I'm asking how can I have an iterator on a
> collection and search for specific objects (with '=' condition). I
> want to use the index of the searched object in my collection (an
> OrdredSet) and do some mappings with elements just before/after it in
> the collection.
> Something like this :
> var aList := A->asOrderedSet();
> var obj := --some instance -- have some iterator 'iter' in A
> if ( obj = iter) {
> getIndex(iter)
> -- use A.get(iter+1)
> }
>
>
> Thanks in advance
>
> Amine
Previous Topic:[ATL] MoDisco .javaxmi files
Next Topic:[Xtend] Cannot create instance of abstract class
Goto Forum:
  


Current Time: Wed Oct 01 12:14:01 GMT 2014

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

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