#REFACTORING by stefan
class: OrderedSet
added: #findLast:ifNone:
changed: #testAndAdd:
--- 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.
! !