load help;

@[name]
dao.type.map
@[name]

@[title]
Map or Hash Map Container Type
@[title]

@[text]
Dao supports map and hash map as a  single type @[green]map@[green].
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
@[green]=>@[green] is used for map and @[green]:@[green] is used for hash map.

@[subsection]Definition@[subsection]
@[code(syntax)]
MapKeyValueList ::= Expression => Expression { ',' Expression => Expression }
HashKeyValueList ::= Expression : Expression { ',' Expression : Expression }

MapEnumeration  ::= [ 'map' ] '{' MapKeyValueList '}'
HashEnumeration ::= [ 'map' ] '{' HashKeyValueList '}'

Map ::= MapEnumeration | HashEnumeration
@[code(syntax)]


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


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


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


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


Get size, keys and values,
@[code]
io.writeln( %hash1 )         # get size;
io.writeln( map2.size() )    # get size;
io.writeln( map2.keys() )    # get keys;
io.writeln( map2.values() )  # get values;
@[code]


Alternative way to define map/hash,
@[code]
map2  = map{ 'ABC' => 123, 'DEF' => 456 }
hash2 = map{ 'ABC' -> 123, 'DEF' -> 456 }
@[code]


Iterate over maps,
@[code]
for( keyvalue in map1 ) io.writeln( keyvalue )
for( keyvalue in hash1 ) io.writeln( keyvalue )
@[code]


@[text]



@[name]
dao.type.map.method
@[name]

@[text]
@[code]
clear( self :map<any,any> )
reset( self :map<any,any> )
reset( self :map<any,any>, hashing :enum<none,default,random> )
erase( self :map<any,any> )
erase( self :map<@K,@V>, from :@K )
erase( self :map<@K,@V>, from :@K, to :@K )
insert( self :map<@K,@V>, key :@K, value :@V )
find( self :map<@K,@V>, key :@K, type :enum<le,eq,ge>=$eq )=>tuple<key:@K,value:@V>|none
keys( self :map<@K,any>, from :@K )=>list<@K>
keys( self :map<@K,any>, from :@K, to :@K )=>list<@K>
values( self :map<@K,@V>, from :@K )=>list<@V>
values( self :map<@K,@V>, from :@K, to :@K )=>list<@V>
has( self :map<@K,any>, key :@K )=>int
size( self :map<any,any> )=>int

iterate( self :map<@K,@V> )[key :@K, value :@V]
count( self :map<@K,@V> )[key :@K, value :@V =>int] =>int
keys( self :map<@K,@V> )[key :@K, value :@V =>int] =>list<@K>
values( self :map<@K,@V> )[key :@K, value :@V =>int] =>list<@V>
select( self :map<@K,@V> )[key :@K, value :@V =>int] =>list<tuple<key:@K,value:@V>>
find( self :map<@K,@V> )[key :@K, value :@V =>int] =>tuple<key:@K,value:@V>|none
map( self :map<@K,@V> )[key :@K, value :@V =>@T] =>list<@T>
apply( self :map<@K,@V> )[key :@K, value :@V =>@V] =>map<@K,@V>
@[code]
@[text]
