#TUNING by cg
authorClaus Gittinger <cg@exept.de>
Sat, 09 Feb 2019 15:26:54 +0100
changeset 23687 d50488d89e81
parent 23686 ba39384235e5
child 23688 287442aafcd9
#TUNING by cg class: Interval added: #isEmpty
Interval.st
--- a/Interval.st	Sat Feb 09 15:06:39 2019 +0100
+++ b/Interval.st	Sat Feb 09 15:26:54 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
@@ -473,6 +475,27 @@
 
 !Interval methodsFor:'queries'!
 
+isEmpty
+    "return true, if the receiver is empty"
+
+    step > 0 ifTrue:[
+        ^ stop < start
+    ].
+    ^ stop > start
+
+    "
+     self assert:(1 to:1) isEmpty not
+     self assert:(1 to:0) isEmpty 
+     self assert:(0 to:1) isEmpty not
+
+     self assert:(1 to:1 by:-1) isEmpty not
+     self assert:(1 to:0 by:-1) isEmpty not
+     self assert:(0 to:1 by:-1) isEmpty
+    "
+
+    "Created: / 09-02-2019 / 15:24:32 / Claus Gittinger"
+!
+
 max
     "return the maximum value in the receiver collection,
      redefined, since this can be easily computed.