Getting expression list of all keys
Getting expression list of all values
Number of entries in the map
Filters entries with function or template F, leaving entry only if F returning true.
Filters entries with function or template F passing only a key from an entry, leaving entry only if F returning true.
Getting values by keys. If Keys is a one key, then returns unwrapped value, else a ExpressionExpressionList of values.
Returns true if map has a Key
Applies F template for each pair (key-value).
Setting values to specific keys (or adding new key-values)
1 alias map = KeyValueList!("a", 42, "b", 23); 2 static assert(map.get!"a" == 42); 3 static assert(map.get!("a", "b") == ExpressionList!(42, 23)); 4 static assert(map.get!"c".length == 0); 5 6 alias map2 = KeyValueList!(int, float, float, double, double, 42); 7 static assert(is(map2.get!int == float)); 8 static assert(is(map2.get!float == double)); 9 static assert(map2.get!double == 42); 10 11 static assert(map.has!"a"); 12 static assert(map2.has!int); 13 static assert(!map2.has!void); 14 static assert(!map.has!"c"); 15 16 alias map3 = map.set!("c", 4); 17 static assert(map3.get!"c" == 4); 18 alias map4 = map.set!("c", 4, "d", 8); 19 static assert(map4.get!("c", "d") == ExpressionList!(4, 8)); 20 alias map5 = map.set!("a", 4); 21 static assert(map5.get!"a" == 4); 22 23 template inc(string key, int val) 24 { 25 alias inc = ExpressionList!(key, val+1); 26 } 27 28 alias map6 = map.map!inc; 29 static assert(map6.get!"a" == 43); 30 static assert(map6.get!("a", "b") == ExpressionList!(43, 24)); 31 32 static assert(map.keys == ExpressionList!("a", "b")); 33 static assert(map.values == ExpressionList!(42, 23));
Static associative map. * Pairs is a list of pairs key-value.