DenseHashTable

Hashtable class, used to implement the hashed associative containers hash_set and hash_map.

class DenseHashTable (
Value
Key
HashFcn
ExtractKey
SetKey
EqualKey
) {}

Constructors

this
this(size_t expected_max_items_in_table, HashFcn hashFcn, ExtractKey extractKey, SetKey setKey, EqualKey equalKey)
Undocumented in source.
this
this(DenseHashTableT ht, size_t min_buckets_wanted)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

Iterator
alias Iterator = DenseHashTableIterator!(Value, Key, HashFcn, ExtractKey, SetKey, EqualKey)
Undocumented in source.
KeyType
alias KeyType = Key
Undocumented in source.
ThisT
alias ThisT = DenseHashTable!(Value, Key, HashFcn, ExtractKey, SetKey, EqualKey)
Undocumented in source.
ValueType
alias ValueType = Value
Undocumented in source.

Functions

begin
Iterator begin()
Undocumented in source. Be warned that the author may not have intended to support it.
bucket
size_t bucket(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
bucketCount
size_t bucketCount()
Undocumented in source. Be warned that the author may not have intended to support it.
bucketSize
size_t bucketSize(size_t i)
Undocumented in source. Be warned that the author may not have intended to support it.
clear
void clear()
Undocumented in source. Be warned that the author may not have intended to support it.
clearDeletedKey
void clearDeletedKey()
Undocumented in source. Be warned that the author may not have intended to support it.
clearNoResize
void clearNoResize()
Undocumented in source. Be warned that the author may not have intended to support it.
count
size_t count(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
deletedKey
Key deletedKey()
Undocumented in source. Be warned that the author may not have intended to support it.
empty
bool empty()
Undocumented in source. Be warned that the author may not have intended to support it.
emptyKey
Key emptyKey()
Undocumented in source. Be warned that the author may not have intended to support it.
end
Iterator end()
Undocumented in source. Be warned that the author may not have intended to support it.
equalKey
bool equalKey(Key a, Key b)
Undocumented in source. Be warned that the author may not have intended to support it.
equalRange
Pair!(Iterator, Iterator) equalRange(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
erase
void erase(Iterator pos)
Undocumented in source. Be warned that the author may not have intended to support it.
erase
void erase(Iterator f, Iterator l)
Undocumented in source. Be warned that the author may not have intended to support it.
erase
size_t erase(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
find
Iterator find(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
findOrInsert
Value findOrInsert(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
getKey
Key getKey(Value v)
Undocumented in source. Be warned that the author may not have intended to support it.
getResizingParameters
void getResizingParameters(float shrink, float grow)
Undocumented in source. Be warned that the author may not have intended to support it.
hash
size_t hash(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
insert
Pair!(Iterator, bool) insert(Value obj)
Undocumented in source. Be warned that the author may not have intended to support it.
insert
void insert(Iterator f, Iterator l)
Undocumented in source. Be warned that the author may not have intended to support it.
maxBucketCount
size_t maxBucketCount()
Undocumented in source. Be warned that the author may not have intended to support it.
maxSize
size_t maxSize()
Undocumented in source. Be warned that the author may not have intended to support it.
nonemptyBucketCount
size_t nonemptyBucketCount()
Undocumented in source. Be warned that the author may not have intended to support it.
numTableCopies
int numTableCopies()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Object o)
Undocumented in source. Be warned that the author may not have intended to support it.
resize
void resize(size_t req_elements)
Undocumented in source. Be warned that the author may not have intended to support it.
setDeletedKey
void setDeletedKey(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
setEmptyKey
void setEmptyKey(Value val)
Undocumented in source. Be warned that the author may not have intended to support it.
setKey
void setKey(Value v, Key k)
Undocumented in source. Be warned that the author may not have intended to support it.
setResizingParameters
void setResizingParameters(float shrink, float grow)
Undocumented in source. Be warned that the author may not have intended to support it.
size
size_t size()
Undocumented in source. Be warned that the author may not have intended to support it.
swap
void swap(DenseHashTable ht)
Undocumented in source. Be warned that the author may not have intended to support it.
testDeleted
bool testDeleted(size_t bucknum)
Undocumented in source. Be warned that the author may not have intended to support it.
testDeleted
bool testDeleted(Iterator it)
Undocumented in source. Be warned that the author may not have intended to support it.
testEmpty
bool testEmpty(size_t bucknum)
Undocumented in source. Be warned that the author may not have intended to support it.
testEmpty
bool testEmpty(Iterator it)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

HT_DEFAULT_STARTING_BUCKETS
enum size_t HT_DEFAULT_STARTING_BUCKETS;

By default, if you don't specify a hashtable size at construction-time, we use this size. Must be a power of two, and at least HT_MIN_BUCKETS.

HT_EMPTY_PCT
enum size_t HT_EMPTY_PCT;

How empty we let the table get before we resize lower, by default. (0.0 means never resize lower.) It should be less than OCCUPANCY_PCT / 2 or we thrash resizing.

HT_MIN_BUCKETS
enum size_t HT_MIN_BUCKETS;

Minimum size we're willing to let hashtables be. Must be a power of two, and at least 4. Note, however, that for a given hashtable, the initial size is a function of the first constructor arg, and may be >HT_MIN_BUCKETS.

HT_OCCUPANCY_PCT
enum size_t HT_OCCUPANCY_PCT;

How full we let the table get before we resize. Knuth says .8 is good -- higher causes us to probe too much, though saves memory. However, we go with .5, getting better performance at the cost of more space (a trade-off densehashtable explicitly chooses to make). Feel free to play around with different values, though, via max_load_factor() and/or set_resizing_parameters().

Parameters

Value

what is stored in the table (each bucket is a Value).

Key

something in a 1-to-1 correspondence to a Value, that can be used to search for a Value in the table (find() takes a Key).

HashFcn

A callable type which when given a Key, returns an integer, the more unique the better.

ExtractKey

A callable type which when given a Value, returns the unique Key associated with it. Must inherit from unary_function, or at least have a result_type enum indicating the return type of operator().

SetKey

A callable type which when given a ref Value and a Key, modifies the value such that ExtractKey(value) == key. We guarantee this is only called with key == deleted_key or key == empty_key.

EqualKey

A callable type which when given two Keys, says whether they are the same (that is, if they are both associated with the same Value).

Meta