#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Thu, 16 Feb 2017 14:15:04 +0100
changeset 21460 9eb25f04ec5f
parent 21459 afc01857037e
child 21461 f6d6d64a6a24
#REFACTORING by stefan class: OrderedSet added: #findLast:ifNone: changed: #testAndAdd:
OrderedSet.st
--- a/OrderedSet.st	Thu Feb 16 14:14:42 2017 +0100
+++ b/OrderedSet.st	Thu Feb 16 14:15:04 2017 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2001 by eXept Software AG
               All Rights Reserved
@@ -335,11 +337,13 @@
      If anObject is already present in the set,
      the order will not be changed. (See also: #addLast:)"
 
-    (super testAndAdd:anObject) ifFalse:[
-        order add:anObject.
-        ^ false.
+    (super testAndAdd:anObject) ifTrue:[
+        ^ true
     ].
-    ^ true
+    order add:anObject.
+    ^ false.
+
+    "Modified: / 16-02-2017 / 13:45:50 / stefan"
 ! !
 
 !OrderedSet methodsFor:'converting'!
@@ -420,6 +424,15 @@
     ^ order findFirst:aBlock ifNone:exceptionValue.
 !
 
+findLast:aBlock ifNone:exceptionValue
+    "find the index of the last element, for which evaluation of the argument, aBlock returns true.
+     Return its index or the value from exceptionValue if none detected."
+
+    ^ order findLast:aBlock ifNone:exceptionValue.
+
+    "Created: / 16-02-2017 / 13:55:43 / stefan"
+!
+
 indexOf:anObject
     ^ order indexOf:anObject.
 ! !