Set.st
branchjv
changeset 25382 c7092e143d68
parent 20362 fea6b00ed63a
--- a/Set.st	Sat Jan 25 21:55:08 2020 +0000
+++ b/Set.st	Wed May 20 12:37:38 2020 +0100
@@ -200,6 +200,8 @@
     "Created: / 24.10.1997 / 23:13:44 / cg"
 ! !
 
+
+
 !Set methodsFor:'Compatibility-ST80'!
 
 initialIndexFor:hashKey boundedBy:length
@@ -1294,7 +1296,6 @@
     ^ tally
 ! !
 
-
 !Set methodsFor:'searching'!
 
 findFirst:aBlock ifNone:exceptionValue
@@ -1339,6 +1340,29 @@
     ^ false
 !
 
+isHealthy
+    "Test that object hashes match their positions stored in set's array,
+     answer true if everything ok, false otherwise
+
+     Dictionary allInstances select: [:dict |
+            dict isHealthy not ]
+     Dictionary allSubInstances select: [:dict |
+            dict isHealthy not ]
+    "
+    
+    keyArray 
+        withIndexDo:[:elem :i | 
+            elem notNil ifTrue:[
+                (self findKeyOrNil:elem) == i ifFalse:[
+                    ^ false
+                ]
+            ]
+        ].
+    ^ true
+
+    "Created: / 20-05-2020 / 12:33:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 isOrdered
     "return true, if the receiver's elements are ordered.
      Redefined to return false here, because the order of keys (and values in dictionaries)
@@ -1403,6 +1427,11 @@
 
 version_CVS
     ^ '$Header$'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !