test map from uint to values of type double
version (showAssertTags) dbg(); alias Key = uint; alias Value = uint; auto map = RadixTreeMap!(Key, Value, TestAllocator)(); assert(map.empty); static assert(map.hasValue); static Value keyToValue(Key key) pure nothrow @safe @nogc { return cast(Value)((key + 1)*radix); } foreach (immutable i; 0 .. SparseLeaf1!Value.maxCapacity) { assert(!map.contains(i)); assert(map.length == i); map[i] = keyToValue(i); assert(map.contains(i)); assert(*map.contains(i) == keyToValue(i)); assert(i in map); assert(*(i in map) == keyToValue(i)); assert(map.length == i + 1); } foreach (immutable i; SparseLeaf1!Value.maxCapacity .. radix) { assert(!map.contains(i)); assert(map.length == i); map[i] = keyToValue(i); assert(map.contains(i)); assert(*map.contains(i) == keyToValue(i)); assert(i in map); assert(*(i in map) == keyToValue(i)); assert(map.length == i + 1); } void testRange() @trusted { size_t i = 0; foreach (immutable keyValue; map[]) { assert(keyValue.key == i); assert(keyValue.value == keyToValue(cast(Key)i)); /+ TODO: use typed key instead of cast(Key) +/ ++i; } } testRange();
Calculate and print statistics of tree.