Hi
I've asked this about Dictionaries elsewhere before, but I'm curious as to how Dictionaries store information. I thought, as with OrderedCollection, it'll be stored in the order you put data into a dictionary. Yet it would seem not so. Evaluate below. |aDict| aDict := Dictionary new. aDict at: '1' put: 'one'; at: '2' put: 'two'; at: '3' put: 'three'; at: '4' put: 'four'. aDict inspect. aDict keysAndValuesDo: [:k :v | Transcript cr; show: k,' - ',v]. How do I get the above to process in the order I created them? Kind Regards Dusty -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
I suppose, that instances of dictionay are not a good data structure to
offer this. Marten -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
In reply to this post by Dusty-2
In VA Smalltalk, plain dictionaries store their items in a such a way as
to provide fast access. I believe that there is an OrderedDictionary class that should serve your purpose better. Brad Selfridge On 9/17/2012 7:34 AM, Dusty wrote: > Hi > > I've asked this about Dictionaries elsewhere before, but I'm curious > as to how Dictionaries store information. I thought, as with > OrderedCollection, it'll be stored in the order you put data into a > dictionary. Yet it would seem not so. Evaluate below. > > |aDict| > aDict := Dictionary new. > aDict > at: '1' put: 'one'; > at: '2' put: 'two'; > at: '3' put: 'three'; > at: '4' put: 'four'. > aDict inspect. > aDict keysAndValuesDo: [:k :v | Transcript cr; show: k,' - ',v]. > > How do I get the above to process in the order I created them? > Kind Regards > Dusty > -- Brad Selfridge 913-829-6980 -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Brad Selfridge
|
In reply to this post by Dusty-2
Dusty,
IIRC, dictionaries do not have an order. This has to do with hashing and stuff. There's a nice book about hashing in Smalltalk by Andres Valloud if you are interested in (lots of) more details. You can use AbtOrderedDictionary for dictionaries that keep their order. This class is VA specific, so if you care about portability, you should think about alternatives. Or you could use a collection of associations, but then you'd lose methods like at: and at:put: So what exactly is your purpose for Ordered Dictionaries? HTH Joachim Am Montag, 17. September 2012 14:34:26 UTC+2 schrieb Dusty: Hi You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/TzujunXG3owJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
In reply to this post by Marten Feldtmann-2
Try using a AbtOrderedDictionary.
On Mon, Sep 17, 2012 at 7:01 PM, Marten Feldtmann <[hidden email]> wrote: I suppose, that instances of dictionay are not a good data structure to offer this. -- Regards Gaurav Sharma -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
AbtOrderedDictionary seems to solve the problem.
Any performance issues I should be aware of? Joachim, I'm basically trying to use as little code as possible to create seaside interfaces. So creating 20 drop down lists where I can just do keysAndValuesDo: [:e | e is a drop down list] in order is much easier! I just tried AbtOrderedDictionary and it works well. Thanks for the info. On 9/17/12, Gaurav Sharma <[hidden email]> wrote: > Try using a AbtOrderedDictionary. > > On Mon, Sep 17, 2012 at 7:01 PM, Marten Feldtmann < > [hidden email]> wrote: > >> I suppose, that instances of dictionay are not a good data structure to >> offer this. >> >> Marten >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "VA Smalltalk" group. >> To post to this group, send email to [hidden email]. >> To unsubscribe from this group, send email to va-smalltalk+unsubscribe@** >> googlegroups.com <va-smalltalk%[hidden email]>. >> For more options, visit this group at http://groups.google.com/** >> group/va-smalltalk?hl=en<http://groups.google.com/group/va-smalltalk?hl=en> >> . >> >> > > > -- > Regards > Gaurav Sharma > > -- > You received this message because you are subscribed to the Google Groups > "VA Smalltalk" group. > To post to this group, send email to [hidden email]. > To unsubscribe from this group, send email to > [hidden email]. > For more options, visit this group at > http://groups.google.com/group/va-smalltalk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Hi Dusty, Here are a few other ideas (I'm not pushing any of them, just throwing them out there for your consideration). You could keep your data in both an OrderedCollection and a Dictionary or LookupTable, accessing the data from whichever is easier at the moment. I think LookupTables are slightly faster than diictionaries as they don't store the data as associations. If you don't need to find the data by its key, you could keep an OrderedCollection of associations and use a simple #do: to run the associations accessing their keys and values. As for performance, if you are creating lists for Seaside drop downs, I doubt each list would have enough items to impact performance. Lou On Monday, September 17, 2012 10:37:44 AM UTC-4, Dusty wrote: AbtOrderedDictionary seems to solve the problem.-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/_uguK1hUeEQJ. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
In reply to this post by Dusty-2
From a dependency perspective, I would probably use EsOrderedDictionary (the AbtOrderedDictionary superclass) so you don't create unnecessary Abt deps
On Monday, September 17, 2012 10:37:44 AM UTC-4, Dusty wrote: AbtOrderedDictionary seems to solve the problem.-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/zf9hN5M8gi4J. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Es? I will look into that.
As for the amount of information in a drop down, well, we've had some pretty big data sets to work with. I do need the association as I'm doing some complex data mapping. Thanks for all the info. I'm a very novice developer so learning is high on my agenda! On 9/17/12, Seth Berman <[hidden email]> wrote: > From a dependency perspective, I would probably use EsOrderedDictionary > (the AbtOrderedDictionary superclass) so you don't create unnecessary Abt > deps > > On Monday, September 17, 2012 10:37:44 AM UTC-4, Dusty wrote: >> >> AbtOrderedDictionary seems to solve the problem. >> Any performance issues I should be aware of? >> >> Joachim, I'm basically trying to use as little code as possible to >> create seaside interfaces. >> So creating 20 drop down lists where I can just do keysAndValuesDo: >> [:e | e is a drop down list] in order is much easier! >> >> I just tried AbtOrderedDictionary and it works well. Thanks for the info. >> >> >> On 9/17/12, Gaurav Sharma <[hidden email] <javascript:>> wrote: >> > Try using a AbtOrderedDictionary. >> > >> > On Mon, Sep 17, 2012 at 7:01 PM, Marten Feldtmann < >> > [hidden email] <javascript:>> wrote: >> > >> >> I suppose, that instances of dictionay are not a good data structure to >> >> >> >> offer this. >> >> >> >> Marten >> >> >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "VA Smalltalk" group. >> >> To post to this group, send email to >> >> [hidden email]<javascript:>. >> >> >> To unsubscribe from this group, send email to >> va-smalltalk+unsubscribe@** >> >> googlegroups.com <va-smalltalk%...@googlegroups.com <javascript:>>. >> >> For more options, visit this group at http://groups.google.com/** >> >> group/va-smalltalk?hl=en< >> http://groups.google.com/group/va-smalltalk?hl=en> >> >> . >> >> >> >> >> > >> > >> > -- >> > Regards >> > Gaurav Sharma >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "VA Smalltalk" group. >> > To post to this group, send email to >> > [hidden email]<javascript:>. >> >> > To unsubscribe from this group, send email to >> > [hidden email] <javascript:>. >> > For more options, visit this group at >> > http://groups.google.com/group/va-smalltalk?hl=en. >> > >> > >> > > -- > You received this message because you are subscribed to the Google Groups > "VA Smalltalk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/va-smalltalk/-/zf9hN5M8gi4J. > To post to this group, send email to [hidden email]. > To unsubscribe from this group, send email to > [hidden email]. > For more options, visit this group at > http://groups.google.com/group/va-smalltalk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en. |
Free forum by Nabble | Edit this page |