--- a/HierarchicalItem.st Thu Apr 05 17:09:51 2001 +0200
+++ b/HierarchicalItem.st Wed Apr 11 11:03:55 2001 +0200
@@ -812,6 +812,36 @@
]
!
+keysAndValuesDo:aTwoArgBlock
+ "evaluate the argument, aBlock for every child,
+ passing both index and element as arguments."
+
+ |children|
+
+ children := self children.
+
+ children size ~~ 0 ifTrue:[
+ self criticalDo:[
+ children keysAndValuesDo:aTwoArgBlock
+ ]
+ ].
+!
+
+keysAndValuesReverseDo:aTwoArgBlock
+ "evaluate the argument, aBlock in reverse order for every
+ child, passing both index and element as arguments."
+
+ |children|
+
+ children := self children.
+
+ children size ~~ 0 ifTrue:[
+ self criticalDo:[
+ children keysAndValuesReverseDo:aTwoArgBlock
+ ]
+ ].
+!
+
recursiveCollect:aBlock
"for each child in the receiver, evaluate the argument, aBlock
and return a new collection with the results
@@ -1443,6 +1473,26 @@
!
+findFirst:aOneArgBlock
+ "find the first child, for which evaluation of the argument, aOneArgBlock
+ returns true; return its index or 0 if none detected.
+ "
+ self keysAndValuesDo:[:aChild :anIndex|
+ (aOneArgBlock value:aChild) ifTrue:[^ anIndex]
+ ].
+ ^ 0
+!
+
+findLast:aOneArgBlock
+ "find the last child, for which evaluation of the argument, aOneArgBlock
+ returns true; return its index or 0 if none detected.
+ "
+ self keysAndValuesReverseDo:[:aChild :anIndex|
+ (aOneArgBlock value:aChild) ifTrue:[^ anIndex]
+ ].
+ ^ 0
+!
+
identityIndexOf:aChild
"return the index of aChild or 0 if not found. Compare using ==
"
@@ -1634,5 +1684,5 @@
!HierarchicalItem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.31 2001-04-05 15:09:51 martin Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.32 2001-04-11 09:03:55 ca Exp $'
! !