containers.openhashset
Open-Addressed Hash Set
License
-
Declaration
struct
OpenHashSet
(T, Allocator = Mallocator, alias hashFunction = generateHash!T, bool supportGC = shouldAddGCRange!T);Simple open-addressed hash set. Use this instead of HashSet when the size and quantity of the data to be inserted is small.
Parameters
T
the element type of the hash set
Allocator
the allocator to use. Defaults to
Mallocator
.hashFunction
the hash function to use
supportGC
if
true
, calls to GC.addRange and GC.removeRange will be used to ensure that the GC does not accidentally free memory owned by this container.-
Declaration
this(Allocator
allocator
);Use the given
for allocations.allocator
-
Declaration
this(size_t
initialCapacity
, Allocatorallocator
);Initializes the hash set with the given initial capacity.
Parameters
size_t
initialCapacity
the initial capacity for the hash set
-
Declaration
void
clear
();Removes all items from the hash set.
-
Declaration
const pure nothrow @nogc @property @safe bool
empty
(); -
Declaration
const pure nothrow @nogc @property @safe size_t
length
(); -
Declaration
const bool
contains
(Titem
);
inout boolopBinaryRight
(string op)(Titem
) if (op == "in");Return Value
true
if the hash setcontains
the givenitem
,false
otherwise. -
Declaration
bool
insert
(Titem
);
aliasput
= insert;
aliasinsertAnywhere
= insert;
boolopOpAssign
(string op)(Titem
) if (op == "~");Inserts the given
item
into the set.Return Value
true
if theitem
was inserted,false
if it was already present. -
Declaration
bool
remove
(Titem
);Parameters
T
item
the
item
toremove
Return Value
true
if theitem
was removed,false
if it was not present -
Declaration
pure nothrow @nogc @safe auto
opSlice
(this This)();Return Value
A range over the set.
-