On 2007-09-26, Mark Summerfield <[EMAIL PROTECTED]> wrote: > On 26 Sep, 13:22, Antoon Pardon <[EMAIL PROTECTED]> wrote: >> >> Well you should decide what you want. In a previous exchange one of the >> things that was wanted was that you could already seed a tree by using >> key word arguments so that you could do the following: >> >> t=Tree(a=15, b=30) >> >> which would be equivallent to: >> >> t=Tree() >> t.update(a=15,b=30) >> >> But with the above proposal >> >> t=Tree(cmp=cmp) >> >> is not equivallent to >> >> t=Tree() >> t.update(cmp=cmp) >> >> So it seems the API needs some more sorting out. > > I think you missed some of the previous postings.
That is possible. > > The sorteddict API that has emerged so far is (1) apart from the > constructor, everything is identical to dict, (2) the constructor > takes the same args as sorted(), so if you want to seed with a dict or > with keywords you write sorteddict(dict(a=1,b=2), ...), (or you could > create a sorteddict and use update() since that takes the same args as > dict's constructor). > > Could your AVLTree support cmp and keys and reverse? It already supports cmp. Although for the moment it is done by subclassing. Like the following. class myTree(AVLTree): @staticmethod def cmp(a, b); return .... I don't think adding support for keys will be difficult but it may be tedious. I would prefer not to support reverse because the effect can be acquired by the other two and in contradiction with sorting, I think using it will slow things down instead of speeding things up. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list