--- a/SequenceableCollection.st Fri Nov 10 16:11:38 1995 +0100
+++ b/SequenceableCollection.st Fri Nov 10 16:12:23 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.38 1995-09-08 17:38:17 claus Exp $
+$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.39 1995-11-10 15:12:23 cg Exp $
'!
!SequenceableCollection class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.38 1995-09-08 17:38:17 claus Exp $
+$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.39 1995-11-10 15:12:23 cg Exp $
"
!
@@ -1553,6 +1553,31 @@
"
!
+indexOfAny:aCollection startingAt:start ifAbsent:exceptionBlock
+ "search the collection for an element in aCollection,
+ starting the search at index start;
+ if found, return the index. If not, return the value returned by exceptionBlock.
+ The comparison is done using =
+ (i.e. equality test - not identity test).
+
+ Notice, that for big collections, the runtime of this search
+ grows proportional to size(receiver) * size(aCollection).
+ You may think about using other mechanisms (Sets, Dictionaries etc)."
+
+
+ |val|
+
+ val := self indexOfAny:aCollection startingAt:start .
+ val == 0 ifTrue:[^ exceptionBlock value].
+ ^ val.
+
+ "
+ #(10 20 30 40 10 20 30 40) indexOfAny:#(40 50 30) startingAt:5 ifAbsent:-1
+ #(10 20 30 40 10 20 30 40) indexOfAny:#(40.0 50 30.0) startingAt:5 ifAbsent:-1
+ #(10 20 30 40 10 20 30 40) indexOfAny:#(99 88 77) startingAt:5 ifAbsent:['oops']
+ "
+!
+
lastIndexOf:anElement startingAt:start ifAbsent:exceptionBlock
"search the collection backwards for anElement starting the search at
index start; if found, return the index