--- a/RunArray.st Mon May 13 20:56:43 1996 +0200
+++ b/RunArray.st Tue May 14 15:55:10 1996 +0200
@@ -198,12 +198,11 @@
!RunArray class methodsFor:'instance creation'!
new:size
- "ignore the size argument - we dont know how many runs are
- needed."
+ "return a new runArray, containing size nils"
- ^ self new
+ ^ self basicNew setElement:nil occurrences:size
- "Modified: 11.5.1996 / 14:07:12 / cg"
+ "Modified: 14.5.1996 / 14:04:37 / cg"
!
new:size withAll:anObject
@@ -666,6 +665,14 @@
"
"Modified: 11.5.1996 / 13:34:59 / cg"
+!
+
+asRunArray
+ "return a receiver itself"
+
+ ^ self
+
+ "Modified: 14.5.1996 / 14:59:12 / cg"
! !
!RunArray methodsFor:'enumerating'!
@@ -823,6 +830,37 @@
"Created: 11.5.1996 / 14:05:58 / cg"
! !
+!RunArray methodsFor:'searching'!
+
+findFirst:aBlock
+ "find the first element, for which evaluation of the argument, aBlock
+ returns true; return its index or 0 if none detected.
+ Notice, that not all elements are processed here
+ (the block is only evaluated for each runs first element)."
+
+ |idx|
+
+ idx := 1.
+ contentsArray notNil ifTrue:[
+ contentsArray pairWiseDo:[:len :val |
+ (aBlock value:val) ifTrue:[^ idx].
+ idx := idx + len.
+ ]
+ ].
+ ^ 0
+
+ "
+ (RunArray new
+ add:1 withOccurrences:100;
+ add:2 withOccurrences:100;
+ add:3 withOccurrences:100;
+ add:4 withOccurrences:100;
+ yourself) findFirst:[:el | el == 3]
+ "
+
+ "Modified: 14.5.1996 / 15:54:45 / cg"
+! !
+
!RunArray methodsFor:'user interface'!
inspect
@@ -837,5 +875,5 @@
!RunArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.8 1996-05-12 14:00:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/RunArray.st,v 1.9 1996-05-14 13:55:10 cg Exp $'
! !