Squeak Class Documentation category index | class index  
 
WeakKeyDictionary
  category: Collections-Weak
  superclass: Dictionary
  subclasses: ExternalFormRegistry WeakIdentityKeyDictionary

I am a dictionary holding only weakly on my keys. This is a bit dangerous since at any time my keys can go away. Clients are responsible to register my instances by WeakArray such that the appropriate actions can be taken upon loss of any keys.

See WeakRegistry for an example of use.

instance methods
  accessing
  at:put:
keysDo:

  adding
  add:

  finalization
  finalizeValues
finalizeValues:

  private
  fixCollisionsFrom:
rehash
scanFor:
scanForNil:

class methods
  no messages
 

instance methods
  accessing top  
 

at:put:

Set the value at key to be anObject. If key is not found, create a new
entry for key and set is value to anObject. Answer anObject.


 

keysDo:

Evaluate aBlock for each of the receiver's keys.


  adding top  
 

add:

Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.


  finalization top  
 

finalizeValues

remove all nil keys and rehash the receiver afterwards


 

finalizeValues:

Remove all associations with key == nil and value is in finiObjects.
This method is folded with #rehash for efficiency.


  private top  
 

fixCollisionsFrom:

The element at index has been removed and replaced by nil.


 

rehash

Rehash the receiver. Reimplemented to allow for multiple nil keys


 

scanFor:

ar 10/21/2000: The method has been copied to this location to indicate that whenever #scanFor: changes #scanForNil: must be changed in the receiver as well.


 

scanForNil:

Private. Scan the key array for the first slot containing nil (indicating an empty slot). Answer the index of that slot.


class methods
  no messages top