Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Using Collection.excluding(item)
Using Collection.excluding(item) [message #14546] Fri, 27 March 2009 13:01 Go to next message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Hi there,

In Epsilon, I had wanted to use the Collection.excluding(someObj)
operation to do some bits and bobs, but am not sure if I fully understand
how it is meant to work, or if it works as intended.

In the book pdf it says the operation, excluding, will return a new
Collection minus the specified object (someObj above). Does this mean the
operation does not modify the original Collection? I had assumed this was
the case. However, in the EGL at the end of this message, I find that
'excluding' seems to modify the original Collection:

Could anyone confirm whether or not this is in fact a problem? Any
clarification would be much appreciated.

Thanks!

Edd

---- BEGIN EGL ----
[%
-- make some collection and add 6 elements to it
var os : OrderedSet;
os.add('a1');
os.add('a2');
os.add('a3');
os.add('a4');
os.add('a5');
os.add('a6');
%]

---------------------------------------------------------
In the following, I thought E1 and E2 would produce
the same output if the set, os, is not modified during
evaluation of the 'excluding' operation:
---------------------------------------------------------
[%os.excluding(os.at(0));%]
[%='E1 : os = '+os%]
[%os.excluding(os.at(0));%]
[%='E2 : os = '+os%]
---- END EGL ----
Re: Using Collection.excluding(item) [message #14577 is a reply to message #14546] Fri, 27 March 2009 16:27 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Hi again,

Looking more closely at this issue and the Epsilon source in
org.eclipse.epsilon.eol.types, I noticed that the operation, excluding, in
EolCollection, initiates the calls:

[Collection] createCollection(this.storage)
->
[EolOrderedSet] createCollection(this.storage)
->
new EolOrderedSet(this.storage)
->
EolSet(this.storage)

where EolSet is:

public EolSet(Collection col){
storage = col;
}

... and so this sequence of calls results in a new EolSet being created,
which sets storage = col, and in this case col = this.storage (where this
is the original caller of excluding). So, createCollection does indeed
make a new EolSet, but it stores the original Collection. I may have got
this totally wrong, in which case I apologise!! Anyway, continuing that
trail of thought, is it the case that we want the EolSet constructor to
create a new HashSet? That is:

public EolSet(Collection col){
storage = new HashSet(col);
}

Changing the constructor to this seems to give the result that I
originally expected,

i.e., the following doesn't modify the contents of the os object.
> ...
> [%os.excluding(os.at(0));%]
> ...

Any suggestions are greatly appreciated.

Many thanks in advance.

Edd
Re: Using Collection.excluding(item) [message #14607 is a reply to message #14577] Sun, 29 March 2009 17:42 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Edd,

I do recall this issue in an earlier version of Epsilon, as well as
fixing it. Could you please update to the latest version (0.8.4) and
give it another go?

If memory serves well, you have both the binaries and the SVN code of
Epsilon in your Eclipse instance. I've found that this can sometimes
confuse Eclipse and result in loading the wrong versions of the plugins,
so I'd suggest keeping only one of the two (preferably the SVN version
so that you can pick up future bug-fixes more easily).

Cheers,
Dimitris

Edward Turner wrote:
> Hi again,
>
> Looking more closely at this issue and the Epsilon source in
> org.eclipse.epsilon.eol.types, I noticed that the operation, excluding,
> in EolCollection, initiates the calls:
>
> [Collection] createCollection(this.storage)
> ->
> [EolOrderedSet] createCollection(this.storage)
> ->
> new EolOrderedSet(this.storage)
> ->
> EolSet(this.storage)
>
> where EolSet is:
>
> public EolSet(Collection col){
> storage = col;
> }
>
> .. and so this sequence of calls results in a new EolSet being created,
> which sets storage = col, and in this case col = this.storage (where
> this is the original caller of excluding). So, createCollection does
> indeed make a new EolSet, but it stores the original Collection. I may
> have got this totally wrong, in which case I apologise!! Anyway,
> continuing that trail of thought, is it the case that we want the EolSet
> constructor to create a new HashSet? That is:
>
> public EolSet(Collection col){
> storage = new HashSet(col);
> }
>
> Changing the constructor to this seems to give the result that I
> originally expected,
> i.e., the following doesn't modify the contents of the os object.
>> ...
>> [%os.excluding(os.at(0));%]
>> ...
>
> Any suggestions are greatly appreciated.
>
> Many thanks in advance.
>
> Edd
>
Re: Using Collection.excluding(item) [message #14637 is a reply to message #14607] Mon, 30 March 2009 07:29 Go to previous message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Ah, yes, that seems to have fixed things... great!

Many thanks!

Edd
Re: Using Collection.excluding(item) [message #566181 is a reply to message #14546] Fri, 27 March 2009 16:27 Go to previous message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Hi again,

Looking more closely at this issue and the Epsilon source in
org.eclipse.epsilon.eol.types, I noticed that the operation, excluding, in
EolCollection, initiates the calls:

[Collection] createCollection(this.storage)
->
[EolOrderedSet] createCollection(this.storage)
->
new EolOrderedSet(this.storage)
->
EolSet(this.storage)

where EolSet is:

public EolSet(Collection col){
storage = col;
}

... and so this sequence of calls results in a new EolSet being created,
which sets storage = col, and in this case col = this.storage (where this
is the original caller of excluding). So, createCollection does indeed
make a new EolSet, but it stores the original Collection. I may have got
this totally wrong, in which case I apologise!! Anyway, continuing that
trail of thought, is it the case that we want the EolSet constructor to
create a new HashSet? That is:

public EolSet(Collection col){
storage = new HashSet(col);
}

Changing the constructor to this seems to give the result that I
originally expected,

i.e., the following doesn't modify the contents of the os object.
> ...
> [%os.excluding(os.at(0));%]
> ...

Any suggestions are greatly appreciated.

Many thanks in advance.

Edd
Re: Using Collection.excluding(item) [message #566203 is a reply to message #14577] Sun, 29 March 2009 17:42 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Edd,

I do recall this issue in an earlier version of Epsilon, as well as
fixing it. Could you please update to the latest version (0.8.4) and
give it another go?

If memory serves well, you have both the binaries and the SVN code of
Epsilon in your Eclipse instance. I've found that this can sometimes
confuse Eclipse and result in loading the wrong versions of the plugins,
so I'd suggest keeping only one of the two (preferably the SVN version
so that you can pick up future bug-fixes more easily).

Cheers,
Dimitris

Edward Turner wrote:
> Hi again,
>
> Looking more closely at this issue and the Epsilon source in
> org.eclipse.epsilon.eol.types, I noticed that the operation, excluding,
> in EolCollection, initiates the calls:
>
> [Collection] createCollection(this.storage)
> ->
> [EolOrderedSet] createCollection(this.storage)
> ->
> new EolOrderedSet(this.storage)
> ->
> EolSet(this.storage)
>
> where EolSet is:
>
> public EolSet(Collection col){
> storage = col;
> }
>
> .. and so this sequence of calls results in a new EolSet being created,
> which sets storage = col, and in this case col = this.storage (where
> this is the original caller of excluding). So, createCollection does
> indeed make a new EolSet, but it stores the original Collection. I may
> have got this totally wrong, in which case I apologise!! Anyway,
> continuing that trail of thought, is it the case that we want the EolSet
> constructor to create a new HashSet? That is:
>
> public EolSet(Collection col){
> storage = new HashSet(col);
> }
>
> Changing the constructor to this seems to give the result that I
> originally expected,
> i.e., the following doesn't modify the contents of the os object.
>> ...
>> [%os.excluding(os.at(0));%]
>> ...
>
> Any suggestions are greatly appreciated.
>
> Many thanks in advance.
>
> Edd
>
Re: Using Collection.excluding(item) [message #566226 is a reply to message #14607] Mon, 30 March 2009 07:29 Go to previous message
No real name is currently offline No real nameFriend
Messages: 92
Registered: July 2009
Member
Ah, yes, that seems to have fixed things... great!

Many thanks!

Edd
Previous Topic:Using Collection.excluding(item)
Next Topic:propertyGetter.invoke
Goto Forum:
  


Current Time: Thu Apr 25 17:10:10 GMT 2024

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

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

Back to the top