eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'WeakIdentitySet':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: WeakIdentitySet


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--IdentitySet
            |
            +--WeakIdentitySet

Package:
stx:libbasic
Category:
Collections-Weak
Version:
rev: 1.51 date: 2023/04/18 09:20:35
user: stefan
file: WeakIdentitySet.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


WeakIdentitySets behave like IdentitySets, as long as the contained
objects are still referenced by some other (non-weak) object.
However, once the last non-weak reference ceases to exist,
the object will be automatically removed from the Weakcollection
(with some delay: it will be removed after the next garbage collect).

This class was added to support dependencies which do not
prevent objects from dying. (i.e. which do not fill up your memory
if you forget to #release it).

copyright

COPYRIGHT (c) 1994 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  new
return a new empty WeakIdentitySet

queries
o  goodSizeFrom: requestedSize
return a good array size for the given argument.
Since WeakIdentitySets are mostly used for dependency management, we typically
have only a small number of elements in the set.
Therefore use exact size for small sets
(instead of rounding up to the next prime 11).


Instance protocol:

accessing
o  firstIfEmpty: exceptionValue
return the first element of the collection or the
value of the exceptionBlock, if empty.
Redefine, since the inherited method does not work if
elements change silently to nil

adding & removing
o  add: newElement
Add the argument, newElement to the receiver.
Returns the argument, newElement (sigh).

Redefined to avoid synchronization problems, in case of interrupts
(otherwise, there could be some other operation on the receiver
done by another process, which garbles my contents)

o  remove: anObject ifAbsent: exceptionBlock
redefined to avoid synchronization problems, in case of interrupts
(otherwise, there could be some other operation on the receiver
done by another process, which garbles my contents)

o  safeRemove: anObject ifAbsent: exceptionBlock
redefined to avoid synchronization problems, in case of interrupts
(otherwise, there could be some other operation on the receiver
done by another process, which garbles my contents)

element disposal
o  update: something with: aParameter from: changedObject
an element died - must rehash

enumerating
o  do: aBlock
perform the block for all members in the collection.
This method has been rewritten to be more robust about
changed contents while enumerating elements (which might
happen during change&update processing, if dependents
are added or removed within the update).

private
o  findKeyOrNil: key
Look for the key in the receiver.
If it is found, return return the index, otherwise
the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present.

Warning: an empty slot MUST be filled by the sender - it is only to be sent
by at:put: / add: - like methods.

o  findKeyOrNilOrDeletedEntry: key
Look for the key in the receiver.
If it is found, return return the index, otherwise
the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present

o  grow
change the number of element slots of the collection to a useful
new size

o  keyContainerOfSize: n
return a container for keys and values of size n.
use WeakArrays here.

testing
o  isWeak
return true if the receiver has weak references to its elements.

o  isWeakCollection
return true, if the receiver has weak references to its elements.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:43:56 GMT