4 ms·
You still fail to understand what being part of multiple data structures means. Shared pointers, separate container to check occupancy, suggesting making a con
by mgaunard 4y ago
You still fail to understand what being part of multiple data structures means.
Shared pointers, separate container to check occupancy, suggesting making a container of pointers, all these things suggest you have no idea how to do hybrid data structures.
The nodes contain the data along with multiple pointers in them to chain them to various data structures they are part of (trees, lists, hash tables etc.). The object in question contains state that is several cache lines long.
You cannot just put the nodes inside your buckets as you don't get to control where the nodes are and cannot invalidate the other data structures. Though I suppose it's a possibility if you know ahead of time how many nodes you're going to need, but then in that case you may be able to go for perfect hashing to begin with (unless you're building some kind of fixed-size cache).
A given object for example can be part of several hash maps, based on the various pieces of state it is useful to index by.
In practice you'd use a pool to allocate all your nodes in blocks. There is no per-node overhead for this allocation strategy.
- TheNumbat 4y agoAgreed - I do mention in the post that open addressing is impractical when using intrusive linked lists, which are common in low level data structures.
- dragontamer 4y agoSo you've at best removed just 8 bytes for rather inconvenient programming for... LinearProbingHashTable<FooBar*, size*2> ChainHashTable<FooBar*, size> Note that linearProbingHashTable only uses 8 bytes per pointer. While ChainHashPointer still needs nextPtr, taking up 16 bytes. The *2 is for 50% load factor on linear table. But we still win on linear if we're at say 75% (simple linear) or 95% load factor (which is doable with Robin Hood)