On Sun, 2009-10-04 at 16:29 +0200, Nicolas wrote:
> Hi,
> 
> I'm trying to use the Gee library, but i have a problem;
> This is the code taken from the vala site:
> 
> using Gee;
> 
> static int main (string[] args) {
> 
>     var map = new HashMap<string, int> ();
>     map.set ("one", 1);
>     map.set ("two", 2);
>     map.set ("three", 3);
>     map["four"] = 4;            // same as map.set ("four", 4)
>     map["five"] = 5;
>     foreach (string key in map.keys) {
>         stdout.printf ("%d\n", map[key]);       // same as map.get (key)
>     }
> 
>     return 0;
> }
> 
> My question is, why when i execute this, the result is:
> 4
> 3
> 1
> 2
> 5
> 
> And not:
> 1
> 2
> 3
> 4
> 5
> 
> Thanks in advance for your response.
> Nicolas.
the hashmap is not sorted. I suggest you read the wikipedia article on
hashmaps and it should be obvious why.

_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to