Re: [Vala] Problem with Gee



Nicolas wrote:
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;
}

Also, instead of looping for .keys and checking map[key] for each one you can get
a signicifant perf boost if you loop over .entries instead (for new libgee versions).


                Martin



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