Re: hash table freeze is useless



On Fri, 5 Nov 1999, David Benson wrote:

> while iterating a frozen hashtable.  (At least according
> to my quick inspection.)  Of course,
> you'd better not delete the node you are visiting.

Being able to delete the node you are visiting is lets you easily implement
search-and-destroy type operations such as, oh, cache expiry and the like.

> No strategy which supports resizing can easily support that
> feature...

It's as easy as advancing to the next node and then deleting the previous one,
which is no longer the currently visited node.  This strategy can be
internalized by the traversal interface so the user can simply go ahead and
delete the visited node.

In kazlib, the ``iterator'' object (hscan_t) knows in advance which node is
going to be visited next, so deleting the currently visited node is of no
consequence. However, deleting the next-to-visit node and then advancing would
be disastrous. (The interface spec makes it clear that the *only* deletion that
may be done without invalidating an iterator is in fact the deletion of the
node most recently returned by the iterator; all other deletions invalidate the
iterator). 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]