SortedCollection with IdentitySet and Index - an alternative ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SortedCollection with IdentitySet and Index - an alternative ?

GLASS mailing list

Is it possible to use an IdentitySet with index structure as some kind of SortedCollection ? Has anyone tried this ? Is the index structure available to get the first or the last item of that Set ?


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: SortedCollection with IdentitySet and Index - an alternative ?

GLASS mailing list
Hi Marten,

Yes, this is exactly what indexes are designed to provide. Consider the following:

| set stream |
set := IdentitySet withAll: #(1 3 5 7 9).
set createEqualityIndexOn: '' withLastElementClass: Integer.
set equalityIndexedPaths.
stream := set selectAsStream: {:each | each > 0}.
stream next -> stream reversed next "1 -> 9"

See chapter 7 of the Programming Guide.

James

On Apr 12, 2018, at 12:50 PM, Marten Feldtmann via Glass <[hidden email]> wrote:

Is it possible to use an IdentitySet with index structure as some kind of SortedCollection ? Has anyone tried this ? Is the index structure available to get the first or the last item of that Set ?

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: SortedCollection with IdentitySet and Index - an alternative ?

GLASS mailing list

Yes I know this and I have to investigate this further on - perhaps in the next release of our software I can change all my SortedCollection to IdentitySets with equality indices and I hope to get much better performance and translog behaviour.

Normally I just need some kind of next, first, removeFirst, last, removeLast and stuff like this ...

Marten


James Foster <[hidden email]> hat am 13. April 2018 um 00:40 geschrieben:

Hi Marten,

Yes, this is exactly what indexes are designed to provide. Consider the following:

| set stream |
set := IdentitySet withAll: #(1 3 5 7 9).
set createEqualityIndexOn: '' withLastElementClass: Integer.
set equalityIndexedPaths.
stream := set selectAsStream: {:each | each > 0}.
stream next -> stream reversed next "1 -> 9"

See chapter 7 of the Programming Guide.

James

On Apr 12, 2018, at 12:50 PM, Marten Feldtmann via Glass < [hidden email]> wrote:

Is it possible to use an IdentitySet with index structure as some kind of SortedCollection ? Has anyone tried this ? Is the index structure available to get the first or the last item of that Set ?

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


 

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: SortedCollection with IdentitySet and Index - an alternative ?

GLASS mailing list
In reply to this post by GLASS mailing list