bugadani / Slots

Fixed size data structure with constant-time operations.
MIT License
2 stars 1 forks source link

Add SlotMap implementation #16

Open chrysn opened 4 years ago

chrysn commented 4 years ago

Based on #11, this is adding a SlotMap implentation.

It is built for the embedded use case (where the number of slots can be counted with a few bits), and packs the generation in the high bits of the key (so access should be a plain mask, get, compare).

I'm not happy yet with the performance -- manipulation is a lot slower than to the plain RawSlots, and I couldn't yet figure out why.

chrysn commented 4 years ago

(Plus this will need some changes to account for the last weeks; I had forgotten to push this right away).

bugadani commented 4 years ago

Thanks for your continued interest in this project :)

Before progressing forward on this front, I think we should first stabilize the split-up unrestricted and "normal" structures (I've redone #11 on top of the latest changes, I'll add iter_mut() and clean up the implementation before merging).

For SlotMap I think there is no reason to try to be clever instead of storing the generation in a different word than the index itself. I'd personally take the performance over some extra bytes of memory.