SegmentedOrderedCollection.st
changeset 3267 4cd1614af5ca
parent 3211 af5cc3c54fa8
child 3327 5b988100c53a
--- a/SegmentedOrderedCollection.st	Sat Apr 26 13:24:48 2014 +0200
+++ b/SegmentedOrderedCollection.st	Sun Apr 27 15:25:54 2014 +0200
@@ -180,10 +180,19 @@
     "remove the first element from the collection; return the element.
      If there is no element in the receiver collection, raise an error."
 
+    ^ self removeFirstIfAbsent:[self emptyCollectionError]
+!
+
+removeFirstIfAbsent:exceptionBlock
+    "remove the first element from the collection; return the element.
+     If there is no element in the receiver collection, return the value from
+     exceptionBlock.
+     Destructive: modifies the receiver"
+
     |seg el|
 
     tally == 0 ifTrue:[
-        ^ self emptyCollectionError
+        ^ exceptionBlock value
     ].
     seg := segments first.
     el := seg removeFirst.
@@ -384,10 +393,10 @@
 !SegmentedOrderedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.8 2014-03-07 22:07:11 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.9 2014-04-27 13:25:54 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.8 2014-03-07 22:07:11 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.9 2014-04-27 13:25:54 cg Exp $'
 ! !