Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Iterator index
OCL Iterator index [message #980065] Sun, 11 November 2012 10:13 Go to next message
Andrea Sindico is currently offline Andrea Sindico
Messages: 266
Registered: November 2010
Senior Member

I need to get the index of an iterator. For instance I have a CallOperationAction which refers to a Class' Operation and takes a set of object as parameters. I need to check whether the passed objects are in number and types compatible with the related operation signature. To this end I am iterating on the Operation parameters as an ordered set and, inside the iterator, I'd like to check if the current parameter (in the right order) has the same type with the i-th object of the call operation action. I therefore need to get the iterator index/counter. Is there any way to do that?

Regards


Follow me on Twitter @andreasindico

Re: OCL Iterator index [message #980169 is a reply to message #980065] Sun, 11 November 2012 12:13 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

The direct/horrible way is to keep computing the index using
orderedCollection->indexOf(anElement).

The idiomatic way is to iterate over the indexes;

Sequence{1..coll1->size()}->forAll(i: Integer |
let a : A = coll1->at(i), b : B = coll2->at(i) in ... )

I think I raised an issue suggesting a forAllWith iteration that gave
you an extra argument.

Regards

Ed Willink


On 11/11/2012 10:13, Andrea Sindico wrote:
> I need to get the index of an iterator. For instance I have a
> CallOperationAction which refers to a Class' Operation and takes a set
> of object as parameters. I need to check whether the passed objects
> are in number and types compatible with the related operation
> signature. To this end I am iterating on the Operation parameters as
> an ordered set and, inside the iterator, I'd like to check if the
> current parameter (in the right order) has the same type with the i-th
> object of the call operation action. I therefore need to get the
> iterator index/counter. Is there any way to do that?
>
> Regards
Previous Topic:Operation Body Expression
Next Topic:[VT] Consultas super r
Goto Forum:
  


Current Time: Sun Sep 21 10:19:29 GMT 2014

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

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