[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 identi
cal 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
     


Examples, 
     
   1  # A map is created using "=>",
   2  var map1 = { 'EE' => 5, 'BB' => 2, 'CC' => 3, 'AA' => 1 }
   3  
   4  #A hash map is created using "->",
   5  var hash1 = { 'EE' -> 5, 'BB' -> 2, 'CC' -> 3, 'AA' -> 1 }
   6  
   7  #Get value by key,
   8  io.writeln( map1['BB'] )
   9  io.writeln( hash1['CC'] )
  10  
  11  #Get sub map/hash by slicing,
  12  io.writeln( map1[ 'AA' : 'CC' ] )
  13  io.writeln( map1[ 'BB' : ] )
  14  io.writeln( map1[ : 'CC' ] )
  15  
  16  # Get size, keys and values,
  17  io.writeln( %hash1 )         # get size;
  18  io.writeln( map2.size() )    # get size;
  19  io.writeln( map2.keys() )    # get keys;
  20  io.writeln( map2.values() )  # get values;
  21  
  22  # Alternative way to define map/hash,
  23  var map2 = map{ 'ABC' => 123, 'DEF' => 456 }
  24  var hash2 = map{ 'ABC' -> 123, 'DEF' -> 456 }
  25  
  26  # Iterate over maps,
  27  for( keyvalue in map1 ) io.writeln( keyvalue )
  28  for( keyvalue in hash1 ) io.writeln( keyvalue )
     



[STRUCTURE]

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