better hash and compare
authorClaus Gittinger <cg@exept.de>
Tue, 10 Sep 2002 13:49:58 +0200
changeset 6745 c2c52940ec99
parent 6744 042f0606f7a6
child 6746 8bbd639df663
better hash and compare
Interval.st
--- a/Interval.st	Fri Sep 06 21:23:03 2002 +0200
+++ b/Interval.st	Tue Sep 10 13:49:58 2002 +0200
@@ -165,6 +165,21 @@
     stop := aNumber
 ! !
 
+!Interval methodsFor:'comparing'!
+
+= anInterval
+    anInterval class == self class ifTrue:[
+        ^ start = anInterval start
+        and:[ stop = anInterval stop
+        and:[ step = anInterval step]]
+    ].
+    ^ super = anInterval
+!
+
+hash
+    ^ ((((step hash bitShift:5) + start hash) bitShift:5) + stop hash) bitAnd:16r3FFFFFFF.
+! !
+
 !Interval methodsFor:'converting'!
 
 fromLiteralArrayEncoding:encoding
@@ -463,5 +478,5 @@
 !Interval class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.33 2002-08-07 22:46:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.34 2002-09-10 11:49:58 cg Exp $'
 ! !