94
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
IdentitySet subclass:#WeakIdentitySet
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
159
|
17 |
category:'Collections-Unordered'
|
94
|
18 |
!
|
|
19 |
|
|
20 |
WeakIdentitySet comment:'
|
|
21 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
22 |
All Rights Reserved
|
|
23 |
|
159
|
24 |
$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.3 1994-10-10 00:29:15 claus Exp $
|
94
|
25 |
'!
|
|
26 |
|
|
27 |
!WeakIdentitySet class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
32 |
All Rights Reserved
|
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
159
|
45 |
$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.3 1994-10-10 00:29:15 claus Exp $
|
94
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
this is a special class to support dependencies which do not
|
|
52 |
prevent objects from dying.
|
|
53 |
"
|
|
54 |
! !
|
|
55 |
|
111
|
56 |
!WeakIdentitySet class methodsFor:'instance creation'!
|
|
57 |
|
|
58 |
new
|
|
59 |
"return a new empty Set"
|
|
60 |
|
|
61 |
^ self new:1
|
|
62 |
! !
|
|
63 |
|
94
|
64 |
!WeakIdentitySet methodsFor:'private'!
|
|
65 |
|
111
|
66 |
goodSizeFor:arg
|
|
67 |
"return a good array size for the given argument.
|
|
68 |
Since WeakIdentitySets are mostly used for dependency management, we typically
|
|
69 |
have only one element in the set. Therefore use exact size for small sets
|
|
70 |
(instead of rounding up to the prime 11)."
|
|
71 |
|
|
72 |
arg <= 10 ifTrue:[^ arg].
|
|
73 |
^ super goodSizeFor:arg
|
|
74 |
!
|
|
75 |
|
94
|
76 |
keyContainerOfSize:n
|
|
77 |
"return a container for keys and values of size n.
|
|
78 |
use WeakArrays here."
|
|
79 |
|
|
80 |
|w|
|
|
81 |
|
|
82 |
w := WeakArray new:n.
|
|
83 |
w watcher:self.
|
|
84 |
^ w
|
|
85 |
! !
|
|
86 |
|
|
87 |
!WeakIdentitySet methodsFor:'element disposal'!
|
|
88 |
|
|
89 |
informDispose
|
|
90 |
"an element died - must rehash"
|
|
91 |
|
|
92 |
self rehash
|
|
93 |
! !
|