Force insert at a given key
james7132 opened this issue · 2 comments
Is it possible to forcibly insert a value at a given key? Either by allocating up to a given key, inserting into a vacant entry, or evicting a already occupied one. I'm in a situation where I need to keep multiple slabs and keep the same key between all of them. Would the bookkeeping make this prohibitively expensive?
The cost of that would be linear time. The slab stores the list of unused indexes by threading a linked list through the slab. Removing something from that linked list requires traversing the entire linked list to find the position that comes before it.
An alternative solution to this pattern is to have one slab, used to determine the index and maintain a freelist, and maintain Vec<Option<T>>
s on the side that share the same indexes.