#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Wed, 27 Jun 2018 08:10:51 +0200
changeset 23135 752c53e34c53
parent 23134 b6056d446cd8
child 23136 bf4d9f8dba5b
#BUGFIX by cg class: OrderedSet added: #removeIdentical:ifAbsent: was missing; therefore removeIdentical left the element in the order!
OrderedSet.st
--- a/OrderedSet.st	Tue Jun 26 21:00:37 2018 +0200
+++ b/OrderedSet.st	Wed Jun 27 08:10:51 2018 +0200
@@ -280,6 +280,36 @@
     ^ self remove:element.
 !
 
+removeIdentical:oldObject ifAbsent:exceptionValueProvider
+    "remove oldObject from the collection and return it.
+     If it was not in the collection return the value of exceptionValueProvider.
+
+     WARNING: do not remove elements while iterating over the receiver."
+
+    |removedObject|
+
+    removedObject := super removeIdentical:oldObject 
+                           ifAbsent:[ ^ exceptionValueProvider value].      
+    order removeIdentical:removedObject.
+
+    ^ removedObject
+
+    "
+     |s ef er|
+
+     s := OrderedSet new. 
+     s add:'abc'.
+     s add:'def'.
+     s add:'ghi'.
+     ef := s detect:[:el | el = 'def'].
+     er := s removeIdentical:ef.
+     s addFirst:er.
+     s
+    "
+
+    "Created: / 27-06-2018 / 08:08:28 / Claus Gittinger"
+!
+
 removeLast
     "remove the last object from the collection and return it.
      If it was not in the collection, raise an error.