add bool cast to hash table for init
This commit is contained in:
parent
f3d1f551cc
commit
a12e8c21e2
@ -513,6 +513,11 @@ struct HashTable(K, V)
|
|||||||
u64 node_count;
|
u64 node_count;
|
||||||
u64 list_count;
|
u64 list_count;
|
||||||
|
|
||||||
|
bool opCast(T)() if(is(T == bool))
|
||||||
|
{
|
||||||
|
return cast(bool)this.list_count;
|
||||||
|
}
|
||||||
|
|
||||||
void opIndexAssign(V value, K key)
|
void opIndexAssign(V value, K key)
|
||||||
{
|
{
|
||||||
Push(&this, key, value);
|
Push(&this, key, value);
|
||||||
@ -618,7 +623,7 @@ Search(K, V)(HashTable!(K, V)* ht, K key)
|
|||||||
LinkedList!(KVPair!(K, V))*
|
LinkedList!(KVPair!(K, V))*
|
||||||
GetList(K, V)(HashTable!(K, V)* ht, K key)
|
GetList(K, V)(HashTable!(K, V)* ht, K key)
|
||||||
{
|
{
|
||||||
u64 hash = Hash(&key);
|
u64 hash = Hash(&key);
|
||||||
u64 index = hash % ht.list_count;
|
u64 index = hash % ht.list_count;
|
||||||
return ht.lists.ptr + index;
|
return ht.lists.ptr + index;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user