containers.treemap
Tree Map
License
-
Declaration
struct
TreeMap
(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
K
the key type
V
the value type
Allocator
the allocator to use. Defaults to
Mallocator
.less
the key comparison function to use
supportGC
true
to support storing GC-allocated objects,false
otherwisecacheLineSize
the size of the internal nodes in bytes
-
Declaration
this();
No default construction if an allocator must be provided.
-
Declaration
this(Allocator
allocator
);Use the given
for allocations.allocator
-
Declaration
@trusted void
insert
(const Kkey
, Vvalue
);Inserts or overwrites the given
key
-value
pair. -
Declaration
void
opIndexAssign
(Vvalue
, const Kkey
);Supports treeMap[
key
] =value
; syntax. -
Declaration
inout auto
opIndex
(this This)(const Kkey
);Supports treeMap[
key
] syntax.Throws
RangeError if the
key
does not exist. -
Declaration
inout @trusted auto
get
(this This)(const Kkey
, lazy VdefaultValue
);Return Value
the value associated with the given
key
, or the given
.defaultValue
-
Declaration
@safe auto
getOrAdd
(this This)(const Kkey
, lazy Vvalue
);If the given
key
does not exist in the TreeMap, adds it with thevalue
defaultValue
.Parameters
K
key
the
key
to look upV
value
the default
value
-
Declaration
bool
remove
(const Kkey
);Removes the
key
→value mapping for the givenkey
.Parameters
K
key
the
key
toremove
Return Value
true
if thekey
existed in the map -
Declaration
inout pure nothrow @nogc @trusted bool
containsKey
(const Kkey
);Return Value
true
if the mapping contains the givenkey
-
Declaration
const pure nothrow @nogc @property @safe bool
empty
();Return Value
true
if the mapping isempty
-
Declaration
inout pure nothrow @nogc @property @safe size_t
length
();Return Value
the number of key→value pairs in the map
-
Declaration
inout pure @property @trusted auto
keys
(this This)();Return Value
a GC-allocated array of the
keys
in the map -
Declaration
inout pure @nogc @trusted auto
byKey
(this This)();Return Value
a range of the keys in the map
-
Declaration
inout pure @property @trusted auto
values
(this This)();Return Value
a GC-allocated array of the
values
in the map -
Declaration
inout pure @nogc @trusted auto
byValue
(this This)();
aliasopSlice
= byValue;Return Value
a range of the values in the map
-
Declaration
inout pure @trusted auto
byKeyValue
(this This)();Return Value
a range of the kev/value pairs in this map. The element type of this range is a struct with
key
andvalue
fields.
-