WeakDependencyDictionary.st
changeset 2297 118f794c4e42
parent 2279 ef0f7f5216c4
child 2299 fc326c7457b4
--- a/WeakDependencyDictionary.st	Wed Jan 29 13:47:19 1997 +0100
+++ b/WeakDependencyDictionary.st	Wed Jan 29 14:17:43 1997 +0100
@@ -49,34 +49,58 @@
 "
 ! !
 
+!WeakDependencyDictionary methodsFor:'private'!
+
+keyContainerOfSize:n
+    "return a container for keys of size n.
+     use WeakArrays here."
+
+    |w|
+
+    w := WeakArray new:n.
+    ^ w
+
+    "Modified: 7.1.1997 / 17:01:15 / stefan"
+! !
+
 !WeakDependencyDictionary methodsFor:'special dependency support'!
 
 removeEmptyDependencyValues
     "special entry for dependency management:
      remove any empty (due to finalization) value WeakArray elements."
 
-    |index t wasBlocked deps o|
+    |index t wasBlocked deps o key b|
 
     "/ careful: this is sent by the finalizer at low prio.
     "/ be prepared for the receiver to change while we walk over
     "/ the value array here ...
 
+"/ 'removeEmptyDependencyValues ...' printCR.
+
+    b := [:el | el notNil and:[el ~~ 0]].
+
     index := 1.
     [index <= keyArray size] whileTrue:[
         "/ get the size again - it could have changed
 
         wasBlocked := OperatingSystem blockInterrupts.
+
         index <= keyArray size ifTrue:[
+            key := keyArray basicAt:index.
+            key == 0 ifTrue:[
+                key := nil.
+            ].
+
             deps := valueArray basicAt:index.
             deps notNil ifTrue:[
                 "/ is it an empty WeakArray ?
 
                 (deps isMemberOf:WeakArray) ifTrue:[
-                    t := deps findFirst:[:el | el notNil and:[el ~~ 0]].
+                    t := deps findFirst:b.
                     t == 0 ifTrue:[
                         "/ yes - nil it
                         valueArray basicAt:index put:nil.
-                        (keyArray basicAt:index) notNil ifTrue:[
+                        key notNil ifTrue:[
                             keyArray basicAt:index put:DeletedEntry.
                             tally := tally - 1.
                         ]
@@ -88,23 +112,34 @@
                         (t := deps size) == 0 ifTrue:[
                             "/ yes - nil it
                             valueArray basicAt:index put:nil.
-                            (keyArray basicAt:index) notNil ifTrue:[
+                            key notNil ifTrue:[
                                 keyArray basicAt:index put:DeletedEntry.
                                 tally := tally - 1.
                             ]
-                        ] ifFalse:[
-                            t == 1 ifTrue:[
-                                "/ careful - it could actually be empty
-                                o := deps firstIfEmpty:nil.
-                                o notNil ifTrue:[
-                                    "/ the set lost an object, and shrunk to size 1
-                                    "/ can now use a WeakArray
-                                    valueArray basicAt:index put:(WeakArray with:o)
-                                ]
-                            ]
+"/                        ] ifFalse:[
+"/                            t == 1 ifTrue:[
+"/                                "/ careful - it could actually be empty
+"/                                o := deps firstIfEmpty:nil.
+"/                                o notNil ifTrue:[
+"/                                    "/ the set lost an object, and shrunk to size 1
+"/                                    "/ can now use a WeakArray
+"/                                    valueArray basicAt:index put:(WeakArray with:o)
+"/                                ] ifFalse:[
+"/                                    key notNil ifTrue:[
+"/                                        keyArray basicAt:index put:DeletedEntry.
+"/                                        tally := tally - 1.
+"/                                    ]
+"/                                ]
+"/                            ]
                         ]
                     ]
                 ]
+            ] ifFalse:[
+                (key notNil and:[key ~~ DeletedEntry]) ifTrue:[
+                    'oops:' print. key printCR.
+                    keyArray basicAt:index put:DeletedEntry.
+                    tally := tally - 1.
+                ]
             ]
         ].
 
@@ -112,16 +147,17 @@
         index := index + 1.
     ].
 
+"/ 'done' printCR.
     "
      Dependencies removeEmptyDependencyValues
     "
 
     "Created: 9.1.1997 / 00:00:28 / cg"
-    "Modified: 27.1.1997 / 15:54:28 / cg"
+    "Modified: 29.1.1997 / 14:17:38 / cg"
 ! !
 
 !WeakDependencyDictionary class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/WeakDependencyDictionary.st,v 1.4 1997-01-27 14:55:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/WeakDependencyDictionary.st,v 1.5 1997-01-29 13:17:43 cg Exp $'
 ! !