SegmentedOrderedCollection.st
changeset 3267 4cd1614af5ca
parent 3211 af5cc3c54fa8
child 3327 5b988100c53a
equal deleted inserted replaced
3266:f25320a4b6e8 3267:4cd1614af5ca
   178 
   178 
   179 removeFirst
   179 removeFirst
   180     "remove the first element from the collection; return the element.
   180     "remove the first element from the collection; return the element.
   181      If there is no element in the receiver collection, raise an error."
   181      If there is no element in the receiver collection, raise an error."
   182 
   182 
       
   183     ^ self removeFirstIfAbsent:[self emptyCollectionError]
       
   184 !
       
   185 
       
   186 removeFirstIfAbsent:exceptionBlock
       
   187     "remove the first element from the collection; return the element.
       
   188      If there is no element in the receiver collection, return the value from
       
   189      exceptionBlock.
       
   190      Destructive: modifies the receiver"
       
   191 
   183     |seg el|
   192     |seg el|
   184 
   193 
   185     tally == 0 ifTrue:[
   194     tally == 0 ifTrue:[
   186         ^ self emptyCollectionError
   195         ^ exceptionBlock value
   187     ].
   196     ].
   188     seg := segments first.
   197     seg := segments first.
   189     el := seg removeFirst.
   198     el := seg removeFirst.
   190     seg isEmpty ifTrue:[
   199     seg isEmpty ifTrue:[
   191         segments removeFirst
   200         segments removeFirst
   382 ! !
   391 ! !
   383 
   392 
   384 !SegmentedOrderedCollection class methodsFor:'documentation'!
   393 !SegmentedOrderedCollection class methodsFor:'documentation'!
   385 
   394 
   386 version
   395 version
   387     ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.8 2014-03-07 22:07:11 stefan Exp $'
   396     ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.9 2014-04-27 13:25:54 cg Exp $'
   388 !
   397 !
   389 
   398 
   390 version_CVS
   399 version_CVS
   391     ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.8 2014-03-07 22:07:11 stefan Exp $'
   400     ^ '$Header: /cvs/stx/stx/libbasic2/SegmentedOrderedCollection.st,v 1.9 2014-04-27 13:25:54 cg Exp $'
   392 ! !
   401 ! !
   393 
   402