Set

Set is a data structure that stores unique values without any particular order.

This $(D_PSYMBOL Set) is implemented using closed hashing. Hash collisions are resolved with linear probing.

T should be hashable with hasher. hasher is a callable that accepts an argument of type T and returns a hash value for it ($(D_KEYWORD size_t)).

Constructors

this
this(size_t n, Allocator allocator)
this(Allocator allocator)

Constructor.

this
this(S init, Allocator allocator)

Initializes this Set from another one.

this
this(R range, Allocator allocator)

Initializes the set from a forward range.

this
this(T[n] array, Allocator allocator)

Initializes the set from a static array.

Members

Aliases

ConstRange
alias ConstRange = .Range!(const HashArray)

The range types for $(D_PSYMBOL Set).

Range
alias Range = .Range!HashArray

The range types for $(D_PSYMBOL Set).

Functions

clear
void clear()

Removes all elements.

insert
size_t insert(T value)

Inserts a new element.

insert
size_t insert(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
insert
size_t insert(R range)

Inserts the value from a forward range into the set.

opAssign
typeof(this) opAssign(S that)

Assigns another set.

opBinaryRight
bool opBinaryRight(U value)

$(D_KEYWORD in) operator.

opIndex
Range opIndex()
ConstRange opIndex()

Returns a bidirectional range over the container.

rehash
void rehash(size_t n)

Sets the number of buckets in the container to at least n and rearranges all the elements according to their hash values.

remove
size_t remove(T value)

Removes an element.

Properties

allocator
shared(Allocator) allocator [@property getter]
bucketCount
size_t bucketCount [@property getter]

Returns current bucket count in the container.

capacity
size_t capacity [@property getter]

Maximum amount of elements this $(D_PSYMBOL Set) can hold without resizing and rehashing. Note that it doesn't mean that the $(D_PSYMBOL Set) will hold exactly $(D_PSYMBOL capacity) elements. $(D_PSYMBOL capacity) tells the size of the container under a best-case distribution of elements.

empty
bool empty [@property getter]

Tells whether the container contains any elements.

length
size_t length [@property getter]

Iterates over the $(D_PSYMBOL Set) and counts the elements.

Variables

maxBucketCount
enum size_t maxBucketCount;

The maximum number of buckets the container can have.

Parameters

T

Element type.

hasher

Hash function for T.

Meta