News for hackers. Stuff that matters.
Re:Optimizing Open Addressing by kazinator on Sunday April 02, 2023 @11:54PM (#35418379)
Nobody talks about the possibility of chained hashing, where the chains are vectors and not linked lists. After hashing the key, you chase only one extra pointer. First the pointer to the table, as usual, from which you get a pointer to the "chain", which is another cache-friendly array.

Open Addressing has an ugly problem with deletion. You can never delete anything, because any present node might be a needed stepping stone to another entry. Chained hashing has no problem with deletion: an item is just spliced out of the list. Similarly, chained hashing with vectors could do the same thing. In any given secondary vector, we know that all the entries hashed to the same slot; we don't have to leave any tombstones. We don't have to move entries to close the gap; we can move the last element of the array to the deleted position and decrement the length.

Chained hashing with linked lists has a nice property when you reorganize the table; you don't have to reallocate any memory or do a lot of writes; just reshuffle the linked list pointers to reassign the nodes to the new chains of the resized table. If chains are vectors, this becomes more of a hassle. When growing the table, we allocate new vectors for the odd chains and then move about half the items from old chains to new chains.

Re:Optimizing Open Addressing by anonymoushn on Monday April 03, 2023 @01:06AM (#35418776)
TFA describes a deletion scheme for open addressing in the first paragraph.
Re:Optimizing Open Addressing by ototot on Monday April 03, 2023 @06:39AM (#35421263)
Sorry what is TFA?
Re:Optimizing Open Addressing by gkbrk on Monday April 03, 2023 @06:48AM (#35421358)
The fucking article.
Re:Optimizing Open Addressing by gonzus on Monday April 03, 2023 @06:51AM (#35421381)
The Fine Article.
Re:Optimizing Open Addressing by kragen on Monday April 03, 2023 @04:15PM (#35430615)
calque of 'rtfm'