[NAME]
ALL.dao.type.map

[TITLE]
Map or Hash Map Container Type

[DESCRIPTION]

Dao supports map and hash map as a single type map. A map contains ordered keys, while 
a hash map contains unordered keys. They can be created by enumeration in almost the
identical way, except that => is used for map and : is used for hash map.
 0.1  Definition 
     
   1  MapKeyValueList ::= Expression => Expression { ',' Expression => Expression }
   2  HashKeyValueList ::= Expression : Expression { ',' Expression : Expression }
   3  
   4  MapEnumeration  ::= [ 'map' ] '{' MapKeyValueList '}'
   5  HashEnumeration ::= [ 'map' ] '{' HashKeyValueList '}'
   6  
   7  Map ::= MapEnumeration | HashEnumeration
     


A map is created using "=>",
     
   1  map1  = { 'EE' => 5, 'BB' => 2, 'CC' => 3, 'AA' => 1 }
     


A hash map is created using "->",
     
   1  hash1 = { 'EE' -> 5, 'BB' -> 2, 'CC' -> 3, 'AA' -> 1 }
     


Get value by key,
     
   1  io.writeln( map1['BB'] )
   2  io.writeln( hash1['CC'] )
     


Get sub map/hash by slicing,
     
   1  io.writeln( map1[ 'AA' : 'CC' ] )
   2  io.writeln( map1[ 'BB' : ] )
   3  io.writeln( map1[ : 'CC' ] )
     


Get size, keys and values,
     
   1  io.writeln( %hash1 )         # get size;
   2  io.writeln( map2.size() )    # get size;
   3  io.writeln( map2.keys() )    # get keys;
   4  io.writeln( map2.values() )  # get values;
     


Alternative way to define map/hash,
     
   1  map2  = map{ 'ABC' => 123, 'DEF' => 456 }
   2  hash2 = map{ 'ABC' -> 123, 'DEF' -> 456 }
     


Iterate over maps,
     
   1  for( keyvalue in map1 ) io.writeln( keyvalue )
   2  for( keyvalue in hash1 ) io.writeln( keyvalue )
     



[STRUCTURE]

dao.type.map--| dao.type.map: Map or Hash Map Container Type (2.8 KB)
              |--method--|