BucketSet

Bucket set class template.

Constructors

this
this(size_t n, float load_factor)

Constructor, uses the default implementation for the bucket element allocator: Elements are allocated by 'new' and stored in a free list.

this
this(IAllocator allocator, size_t n, float load_factor)

Constructor.

Members

Aliases

Bucket
alias Bucket = .Bucket!(V, K)

Bucket type

Classes

Iterator
class Iterator

'foreach' iteration over elements in the set. DO NOT change the element keys during iteration because this will corrupt the map (unless it is guaranteed that the element will go to the same bucket).

Functions

clearBuckets
void clearBuckets(void[] val_init)

Removes all elements from all buckets and sets the values to val_init if val_init is not empty.

get_
Bucket.Element* get_(K key, bool must_exist)

Looks up a mapping from the specified key.

put_
Bucket.Element* put_(K key, bool added)

Adds or updates a mapping from the specified key.

put_
Bucket.Element* put_(K key)

Adds or updates a mapping from the specified key.

remove
bool remove(K key)

Removes the mapping for the specified key.

remove_
bool remove_(K key, void delegate(ref Bucket.Element element) dg)

Removes the mapping for the specified key and optionally invokes dg with the value that is about to be removed.

setNumBuckets
typeof(this) setNumBuckets(uint exp2)

Changes the number of buckets to 2 ^ exp2.

toHash
hash_t toHash(K key)

Calculates the hash value from key.

Inherited Members

From IBucketSet

IAllocator
alias IAllocator = .IAllocator

Convenience type alias for subclasses.

bucket_info
BucketInfo bucket_info;

Map and and bucket statistics like the map length or the number of buckets.

bucket_element_allocator
IAllocator bucket_element_allocator;

Bucket element allocator.

length
size_t length()

Get the length of the buckets.

clear
typeof(this) clear()

Removes all elements from all buckets.

setNumBuckets
typeof(this) setNumBuckets(uint exp2)

Changes the number of buckets to 2 ^ exp2.

redistribute
typeof(this) redistribute(float load_factor)

Changes the number of buckets to the lowest power of 2 that results in a load factor of at least load_factor with the current number of elements.

clear_
typeof(this) clear_(void[] val_init)

Removes all elements from all buckets and sets the values to val_init if val_init is not empty.

clearBuckets
void clearBuckets(void[] val_init)

Removes all elements from all buckets.

calcNumBucketsExp2
uint calcNumBucketsExp2(size_t n, float load_factor)

Calculates the lowest exponent of 2 so that a power of 2 with this exponent is at least n / load_factor.

Parameters

V

value size (.sizeof of the value type), may be 0 to store no value

K

key type

Meta