class: Set
authorStefan Vogel <sv@exept.de>
Tue, 15 Jan 2013 17:33:48 +0100
changeset 14654 32c189acecb6
parent 14653 2f82e25f468c
child 14655 1d2b0650e086
class: Set comment/format in: #collisionCount changed: #collisionsFor:
Set.st
--- a/Set.st	Tue Jan 15 16:02:07 2013 +0100
+++ b/Set.st	Tue Jan 15 17:33:48 2013 +0100
@@ -1066,28 +1066,26 @@
     ].
 
     ^ count
+
+    "
+      self allSubInstances 
+          collect:[:each| each collisionCount -> each] 
+          thenSelect:[:each| each key > 0]
+    "
 !
 
 collisionsFor:key
     "Return the number of searches - 1 required for key"
 
     |index  "{ Class:SmallInteger }"
-     length "{ Class:SmallInteger }"
-     hash "{ Class:SmallInteger }"
-     step "{ Class:SmallInteger }"
-     startIndex probe count|
+     length "{ Class:SmallInteger }" startIndex probe count|
 
     length := keyArray basicSize.
-    hash := (self hashFor:key) bitAnd:16r3FFFFFFF.
-    hash < 16r1FFFFFFF ifTrue:[
-        hash := hash * 2
-    ].
-    startIndex := index := hash \\ length + 1.
-    step:= hash // length + 1.
+    startIndex := index := self initialIndexForKey:key.
 
     count := 0.
     [true] whileTrue:[
-        probe := (keyArray basicAt:index).
+        probe := keyArray basicAt:index.
         (probe notNil and:[key = probe]) ifTrue:[^ count].
         (self slotIsEmpty:probe) ifTrue:[self error:'non existing key'].
 
@@ -1125,6 +1123,7 @@
     ^ tally
 ! !
 
+
 !Set methodsFor:'testing'!
 
 capacity 
@@ -1226,11 +1225,12 @@
 !Set class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.115 2012-08-13 17:11:21 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.116 2013-01-15 16:33:48 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.115 2012-08-13 17:11:21 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.116 2013-01-15 16:33:48 stefan Exp $'
 ! !
 
+
 Set initialize!