swarm-support
[Top][All Lists]
Advanced

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

Re: Drop related problems (SimpleExperBug and Map)


From: Roger M. Burkhart
Subject: Re: Drop related problems (SimpleExperBug and Map)
Date: Fri, 13 Jun 1997 13:10:06 -0500

Benedikt,

>From your message:

> To erase both objects and keys from a map, and drop the keys
> I would thus do something along these lines:
> 
>      anIndex=[theCollection begin:[self getZone]];
> 
>      while((aMember=[anIndex next]))
>            [[anIndex getKey] drop];
>      [anIndex drop];
> 
>      [theCollection removeAll];
> 
> Does that seem right? Note that I do the removeAll call outside
> the loop and after the index has been dropped so as not to confuse
> the index while it is attraversing the collection.

Yes, this is what I was suggesting, and it should work on the current
implementation of maps.

Now that you've laid out it out in such stark code, it makes clear
that there's an added requirement on any further map implementations:
once the keys have been dropped, the map can be left in an invalid state
for inserting or removing any individual entries.  The only thing that is
valid to do with a map after its keys become invalid is to remove all its
entries with removeAll or to drop the entire map.

With map implementations such as balanced trees, removeAll would be more
efficient (proportional to number of members) than simply removing each
member individually (roughly n log n), so it makes sense that we support
a map in a temporarily invalid state after its keys have been dropped.
The map documentation needs to include an explicit note that gives
this license to drop keys or otherwise make them invalid on the way to
final cleanup of current contents.

-Roger



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]