r/cpp • • Jun 23 '26

Two Indexed Hash Tables

https://vnmakarov.github.io/data%20structures/c/c++/open-source/2026/06/23/two-indexed-hash-tables.html
33 Upvotes

6 comments sorted by

View all comments

Show parent comment

3

u/compilersarefun Jun 23 '26

There is no tag value for deleted elements. But there is special index value (~0) for deleted elements. So probing a deleted element requires only checking index after we pass the tag.

Such approach speeds up finding empty elements and table works faster when we have no deleted elements. There is a down side too when we have many deleted elements.

2

u/garnet420 Jun 23 '26

I think if you made your tag nonzero (it's simple to enforce that with a bitwise operation) you could get rid of the index sentinel and get better performance.