containers.treemap
Tree Map
License
-
Declaration
structTreeMap(K, V, Allocator = Mallocator, alias less = "a < b", bool supportGC = shouldAddGCRange!K || shouldAddGCRange!V, size_t cacheLineSize = 64);A key→value mapping where the keys are guaranteed to be sorted.
Parameters
Kthe key type
Vthe value type
Allocatorthe allocator to use. Defaults to
Mallocator.lessthe key comparison function to use
supportGCtrueto support storing GC-allocated objects,falseotherwisecacheLineSizethe size of the internal nodes in bytes
-
Declaration
this();No default construction if an allocator must be provided.
-
Declaration
this(Allocatorallocator);Use the given
for allocations.allocator -
Declaration
@trusted voidinsert(const Kkey, Vvalue);Inserts or overwrites the given
key-valuepair. -
Declaration
voidopIndexAssign(Vvalue, const Kkey);Supports treeMap[
key] =value; syntax. -
Declaration
inout autoopIndex(this This)(const Kkey);Supports treeMap[
key] syntax.Throws
RangeError if the
keydoes not exist. -
Declaration
inout @trusted autoget(this This)(const Kkey, lazy VdefaultValue);Return Value
the value associated with the given
key, or the given.defaultValue -
Declaration
@safe autogetOrAdd(this This)(const Kkey, lazy Vvalue);If the given
keydoes not exist in the TreeMap, adds it with thevaluedefaultValue.Parameters
Kkeythe
keyto look upVvaluethe default
value -
Declaration
boolremove(const Kkey);Removes the
key→value mapping for the givenkey.Parameters
Kkeythe
keytoremoveReturn Value
trueif thekeyexisted in the map -
Declaration
inout pure nothrow @nogc @trusted boolcontainsKey(const Kkey);Return Value
trueif the mapping contains the givenkey -
Declaration
const pure nothrow @nogc @property @safe boolempty();Return Value
trueif the mapping isempty -
Declaration
inout pure nothrow @nogc @property @safe size_tlength();Return Value
the number of key→value pairs in the map
-
Declaration
inout pure @property @trusted autokeys(this This)();Return Value
a GC-allocated array of the
keysin the map -
Declaration
inout pure @nogc @trusted autobyKey(this This)();Return Value
a range of the keys in the map
-
Declaration
inout pure @property @trusted autovalues(this This)();Return Value
a GC-allocated array of the
valuesin the map -
Declaration
inout pure @nogc @trusted autobyValue(this This)();
aliasopSlice= byValue;Return Value
a range of the values in the map
-
Declaration
inout pure @trusted autobyKeyValue(this This)();Return Value
a range of the kev/value pairs in this map. The element type of this range is a struct with
keyandvaluefields.
-