WeakIdentitySet.st
author claus
Mon, 10 Oct 1994 01:29:28 +0100
changeset 159 514c749165c3
parent 111 9cdd0ed47f38
child 187 a5dc8e2fa93f
permissions -rw-r--r--
*** empty log message ***

"
 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.
"

IdentitySet subclass:#WeakIdentitySet
       instanceVariableNames:''
       classVariableNames:''
       poolDictionaries:''
       category:'Collections-Unordered'
!

WeakIdentitySet comment:'
COPYRIGHT (c) 1994 by Claus Gittinger
              All Rights Reserved

$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.3 1994-10-10 00:29:15 claus Exp $
'!

!WeakIdentitySet class methodsFor:'documentation'!

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.
"
!

version
"
$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.3 1994-10-10 00:29:15 claus Exp $
"
!

documentation
"
    this is a special class to support dependencies which do not
    prevent objects from dying.
"
! !

!WeakIdentitySet class methodsFor:'instance creation'!

new
    "return a new empty Set"

    ^ self new:1
! !

!WeakIdentitySet methodsFor:'private'!

goodSizeFor:arg
    "return a good array size for the given argument.
     Since WeakIdentitySets are mostly used for dependency management, we typically
     have only one element in the set. Therefore use exact size for small sets
     (instead of rounding up to the prime 11)."

    arg <= 10 ifTrue:[^ arg].
    ^ super goodSizeFor:arg
!

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

    |w|

    w := WeakArray new:n.
    w watcher:self.
    ^ w
! !

!WeakIdentitySet methodsFor:'element disposal'!

informDispose
    "an element died - must rehash"

    self rehash
! !