Examples
// create a new Hash // you can also omit the Type Parameter <Int>, because // it's inferred through the first set operation var hash = new Hash<Int>(); hash.set("coffee", 1); hash.set("tea", 2); hash.set("beer", 3); trace( hash.get("tea") ); // 2 trace( hash.get("juice") ); // null trace( hash.exists("juice") ); // false trace( hash.exists("coffee") ); // true // iterate over the keys for ( key in hash.keys() ) { trace( key ); // unsorted order of coffee, tea, beer } // iterate over the elements for ( elem in hash) { trace( elem ); // unsorted order of 1,2,3 } // get element count trace( Lambda.count( hash ) ); // 3 // remove an element hash.remove("coffee"); // get element count again trace( Lambda.count( hash ) ); // 2
version #8020, modified 2010-02-05 13:14:14 by hhoelzer