RE : Get ordered dict keys

"CHARBONNIER Christophe" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
I implemented a little "tri a bulles" algorithm (""bubble ordering"") like this:
(not very fast nor readable, but it works)

    // List ordering
    n = list_len(my_list);
    for (i = 0; i < n; i++)
      for (j = 0; j < n - i - 1; j++)
      {
        if (octstr_compare(list_get(my_list, j), list_get(my_list, j + 1)) > 0)
        {
          list_insert(my_list, j, list_get(my_list, j + 1));
          list_delete(my_list, j + 2, 1);
        }
      }

-----Message d'origine-----
De : Stipe Tolj [mailto:[email protected]] 
Envoyé : mardi 29 juillet 2003 16:53
À : CHARBONNIER Christophe
Cc : [email protected]
Objet : Re: Get ordered dict keys


> Is there a (simple) way to get the keys of a Dict structure in an 
> ordered manner ??

that's the major problem with simple hash tables, they are not ordered in terms of their contents and the keys that are defined.

To obtain this you would have to implement overhead binary tree structures to the hash to provide a feasable search and ordering on the structure.

I don't think you can have a simple way in obtaining the key in an ordered way from a Dict. (please don't flame me if I'm wrong ;)
 
Stipe

[email protected]
-------------------------------------------------------------------
Wapme Systems AG

Vogelsanger Weg 80
40470 Düsseldorf

Tel: +49-211-74845-0
Fax: +49-211-74845-299

E-Mail: [email protected]
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.