Interval.st
changeset 7820 8e6e0f75767a
parent 6748 604366d06326
child 7821 a8fd1f2b07dd
--- a/Interval.st	Wed Jan 07 13:14:20 2004 +0100
+++ b/Interval.st	Wed Jan 07 13:49:50 2004 +0100
@@ -482,10 +482,39 @@
      (-1 to:-15 by:-4) min    
      (-1 to:15 by:-1) min   -> error   
     "
+!
+
+minMax
+    "return the minimum and maximum values in the receiver collection
+     as a two element array, using #> to compare elements.
+     Raises an error, if the receiver is empty."
+
+    step == -1 ifTrue:[
+        stop <= start ifTrue:[
+            ^ Array with:stop with:start
+        ]
+    ].
+    step == 1 ifTrue:[
+        stop >= start ifTrue:[
+            ^ Array with:start with:stop
+        ]
+    ].
+    ^ super minMax
+
+    "
+     (0 to:15) minMax           
+     (0 to:15 by:2) minMax      
+     (0 to:15 by:8) minMax      
+     (15 to:0) minMax          -> error
+     (15 to:0 by:4) minMax     -> error     
+     (-1 to:-15 by:-1) minMax    
+     (-1 to:-15 by:-4) minMax    
+     (-1 to:15 by:-1) minMax   -> error   
+    "
 ! !
 
 !Interval class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.36 2002-09-10 13:03:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.37 2004-01-07 12:49:50 cg Exp $'
 ! !