Thank you, it's working beautifully Hernán :)

2010/7/12 Hernán Morales Durand <[email protected]>

> Hi Joel,
>
> You may try the attached OrderedDictionary, I've been using it for some
> time.
> Cheers,
>
> Hernán
>
> 2010/7/12 Joel Turnbull <[email protected]>:
> >
> > Spent some time but was not quite able to get OrderedDictionary working.
> > However I see the idea is for the Dictionary to hold an OrderedCollection
> > that is synchronized with the Dictionary's array.
> >
> > I think that's enough for me to go on to implement my own for the limited
> > dictionary protocol I need to support.
> >
> > I looked in the Seaside packages for subclasses of Dictionary, or classes
> > named like Dictionary, but I didn't find anything.
> >
> > I got a little lost looking at BTree, I should probably take the time to
> > look at that  someday.
> >
> > Thanks guys.
> >
> >
> >
> > On Sun, Jul 11, 2010 at 11:45 AM, Levente Uzonyi <[email protected]> wrote:
> >>
> >> On Sun, 11 Jul 2010, Joel Turnbull wrote:
> >>
> >>> What is the group's recommendation for creating a sequential
> Dictionary?
> >>> i.e. A Dictionary who's associations are ordered.
> >>>
> >>> Is there any precedent for this? Or does it sound like I'm barking up
> the
> >>> wrong tree?
> >>>
> >>> In my model, I've subclassed Dictionary into QuantityDictionary to
> store
> >>> line items, where the key is the item and the value is the quantity of
> >>> the
> >>> item. It validates that the value is always a numeric, removes the
> >>> association when the value goes below zero, and other stuff specific to
> >>> my
> >>> application.
> >>>
> >>> Now I'm finding it makes sense to be able to order these associations.
> >>> Imagine a recipe ingredient list, where you add and edit quantities of
> >>> ingredients, and you want to put the ingredients that you use earliest
> in
> >>> the recipe at the top of the ingredient list.
> >>>
> >>> Before I put any more work into it, I just wanted to make sure that a
> >>> sequential dictionary makes sense, and get your ideas on how to
> generally
> >>> go
> >>> about implementing that?
> >>
> >> A "sequential dictionary" can mean a lot of different things. There are
> >> some implementations with different semantics available. See these for
> >> example:
> >> http://squeaksource.com/BTree.html
> >> http://forum.world.st/OrderedDictionary-td277320.html
> >>
> >> If you just want to iterate over your dictionary once in the sorted
> order,
> >> then the best thing to do is to collect your data into an array, sort
> the
> >> array, then iterate over that sorted array.
> >>
> >>
> >> Levente
> >>
> >>>
> >>> Thanks.
> >>>
> >>
> >> _______________________________________________
> >> Pharo-project mailing list
> >> [email protected]
> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [email protected]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to