OrderedDictionary (was: Re: [squeak-dev] Re: The Trunk:
Collections-mt.593.mcz)
Levente Uzonyi
leves at elte.hu
Thu Jan 15 19:22:19 UTC 2015
I find the OrderedDictionary implementation similar to the one in Pharo,
and therefore sub-optimal. The order variable is only used to iterate
over the associations in insertion/update order.
Such behavior can achieved with a LinkedDictionary implementation, which
provides O(1) average time for all lookup-based operations, and can also
support different behaviors (order by last access instead of order by
insertion/update) within the same time constraints.
When I implement such linked dictionaries (see LRUCache, or OCompletition
for examples), I usually link the values, because that way I can use any
dictionary. For a general purpose linked dictionary, the links can be
added to the associations to hide the details from the user.
Other than this, I found the following issues with the code after a quick
look:
- #scanOrderFor: sends #order, which is not implemented.
- #add: evaluates [index := self scanOrderFor: anAssociation key.] twice.
The second evaluation seems to be unnecessary.
- The class comment doesn't state it everywhere that the big O notation
applies to time, not space.
Can you give me some examples when/where you needed an ordered dictionary?
Levente
On Thu, 15 Jan 2015, Marcel Taeumel wrote:
> Well, it was just a little programming exercise for me. Let's discuss whether
> you like it or not. ;) I did need such a container several times in the
> past. Maybe there is a reason why Squeak did not have it? :)
>
> Best,
> Marcel
>
>
>
> --
> View this message in context: http://forum.world.st/The-Trunk-Collections-mt-593-mcz-tp4799750p4799754.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>
More information about the Squeak-dev
mailing list
|