mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Fix ctor with LocalHeap in ClosedHashTable
Set mask, round up size to next power of 2
This commit is contained in:
parent
3ebe0649f2
commit
7f4b96fe11
@ -582,38 +582,28 @@ namespace ngcore
|
|||||||
size_t size;
|
size_t size;
|
||||||
size_t mask;
|
size_t mask;
|
||||||
///
|
///
|
||||||
size_t used;
|
size_t used = 0;
|
||||||
///
|
///
|
||||||
Array<T_HASH> hash;
|
Array<T_HASH> hash;
|
||||||
///
|
///
|
||||||
Array<T> cont;
|
Array<T> cont;
|
||||||
///
|
///
|
||||||
T_HASH invalid;
|
T_HASH invalid = -1;
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
ClosedHashTable (size_t asize = 128)
|
ClosedHashTable (size_t asize = 128)
|
||||||
: size(RoundUp2(asize)), used(0), hash(size), cont(size)
|
: size(RoundUp2(asize)), hash(size), cont(size)
|
||||||
{
|
{
|
||||||
mask = size-1;
|
mask = size-1;
|
||||||
invalid = -1;
|
|
||||||
hash = T_HASH(invalid);
|
hash = T_HASH(invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClosedHashTable (ClosedHashTable && ht2) = default;
|
ClosedHashTable (ClosedHashTable && ht2) = default;
|
||||||
|
|
||||||
// who needs that ?
|
|
||||||
ClosedHashTable (FlatArray<T_HASH> _hash, FlatArray<T> _cont)
|
|
||||||
: size(_hash.Size()), used(0), hash(_hash.Size(), _hash.Addr(0)), cont(_cont.Size(), _cont.Addr(0))
|
|
||||||
{
|
|
||||||
invalid = -1;
|
|
||||||
hash = T_HASH(invalid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// allocate on local heap
|
/// allocate on local heap
|
||||||
ClosedHashTable (size_t asize, LocalHeap & lh)
|
ClosedHashTable (size_t asize, LocalHeap & lh)
|
||||||
: size(asize), hash(asize, lh), cont(asize, lh)
|
: size(RoundUp2(asize)), mask(size-1), hash(size, lh), cont(size, lh)
|
||||||
{
|
{
|
||||||
invalid = -1;
|
|
||||||
hash = T_HASH(invalid);
|
hash = T_HASH(invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user