Set

An unordered set. Internally a hash table. Value-semantics.

Constructors

this
this(Stuff data)

constructor that gets content from arbitrary range

Postblit

this(this)
this(this)

post-blit that does a full copy

Members

Aliases

ConstRange
alias ConstRange = .Range!(const(V), const(Node))
Undocumented in source.
ImmutableRange
alias ImmutableRange = .Range!(immutable(V), immutable(Node))
Undocumented in source.
Range
alias Range = .Range!(V, Node)

Range types for iterating over elements of the set. Implements std.range.isForwardRange

Functions

add
bool add(V value)

Add an element to the set.

add
size_t add(Stuff data)

Add elements from a range to the set.

empty
bool empty()
find
inout(V)* find(const(T) value)
findNode
inout(Node)* findNode(const(T) value)

private helper, null if not found

length
size_t length()
opIn_r
bool opIn_r(const(T) value)
opSlice
Range opSlice()
ConstRange opSlice()
ImmutableRange opSlice()

default range, iterates over everything in arbitrary order

remove
bool remove(const(T) value)

Remove an element from the set.

remove
size_t remove(Stuff data)

Remove multiple elements from the set.

reserve
void reserve(size_t size)

Resize hashtable such that the set can contain minSize elements without further resizing. Note that allocation still occurs on addition, even after using reserve.

Examples

basic usage

Set!int a;
assert(a.add(1) == true);
assert(a.add([4,2,3,1,5]) == 4);
assert(a.remove(7) == false);
assert(a.remove([1,1,8,2]) == 2);
assert(a.remove(3) == true);
assert(a.length == 2);

Meta