Re: [Vala] Problem with Gee



Hi Didier,

Thanks for your response,
I'm learning programming, so don't hesitate to contact me in french, i must understand than english.

So, if i use "Map<string, int> map = new TreeMap<string,int> ();" instead of "var map = new HashMap<string, int> ();" the result is the same !

The only solution i found is using this (in genie):

list.add(value)
dict.set(value, "something")

for o in list
   type = dict[o]
   print "key is " + o
   print "value is " + type

Nicolas.

Hi Nicolas,

HashMap do not maintain order for its keys. In contradiction to that, TreeMap is
a map that naturally maintains ordering of its entries, by using the supplied
comparison function, of the standard comparison function for the key type.

Thus you could do:
Map<string, int> map = new TreeMap<string,int> ();

On that map, you can do insertion of the entries in any order, the resulting
entries will always be sorted by its keys.

I hope this is what you wanted.

Best regards, Didier.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]