[Glass] OrderedDictionary

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

[Glass] OrderedDictionary

GLASS mailing list
Hi all!

Is there a association based Dictionary in Gemstone that preserves order?

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

Re: [Glass] OrderedDictionary

Richard Sargent
Administrator
Is there a association based Dictionary in Gemstone that preserves order?
I've never seen one with associations and order preserving. Do you really need both?
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] OrderedDictionary

GLASS mailing list
On 01/29/2015 04:28 PM, Richard Sargent via Glass wrote:
>
>> Is there a association based Dictionary in Gemstone that preserves order?
>
> I've never seen one with associations and order preserving. Do you really
> need both?

Sebastian, I assume you mean a dictionary where values can be looked up
by keys, and enumeration is sorted by key order?

I agree with Richard that Smalltalk does not traditionally offer that
combination in a single collection. But I've also wanted such a thing
occasionally. Fortunately, it's easy to implement your own, made out of
a regular Dictionary (in GemStone, use a KeyValueDictionary instead of a
Dictionary for somewhat better performance) and a SortedCollection of
the keys.

This approach uses more space than the theoretical minimum. Since it
stores two references to each key the space used is proportional to 3N
instead of the minimum of 2N. It would be possible to create a
tree-based dictionary (which some other languages have) that would
perform better, but that would be more work. The simple approach is
likely to work well for you, unless your dictionaries will be very large
(millions or more).

Regards,

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

Re: [Glass] OrderedDictionary

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

In Grease (loaded by default in GLASS/GsDevKit) there is
GRSmallDictionary and GrOrderedMultiMap. Both preserve the order in
which keys are added  ... Reuse or build your own depends upon any
additional characteristics that you might require....

Dale

On 01/29/2015 11:05 AM, Sebastian Heidbrink via Glass wrote:

> Hi all!
>
> Is there a association based Dictionary in Gemstone that preserves order?
>
> Thanks!
> Sebastian
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass

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