OrderedCollection.st
changeset 679 d3165edbb098
parent 629 2ceefe9b5a19
child 1071 5875a6eedd28
--- a/OrderedCollection.st	Mon Dec 04 18:19:49 1995 +0100
+++ b/OrderedCollection.st	Tue Dec 05 13:38:23 1995 +0100
@@ -642,6 +642,26 @@
      procesing elements in reverse direction (i.e. starting with the last)"
 
     contentsArray from:firstIndex to:lastIndex reverseDo:aBlock
+!
+
+keysAndValuesReverseDo:aTwoArgBlock
+    "evaluate the argument, aBlock for every element in the collection,
+     passing both index and element as arguments."
+
+    |start  "{ Class:SmallInteger }"
+     stop   "{ Class:SmallInteger }" |
+
+    stop := lastIndex.
+    start := firstIndex.
+    stop to:start by: -1 do:[:index |
+	aTwoArgBlock value:index value:(contentsArray at:index)
+    ]
+
+    "
+     #(10 20 30 40) asOrderedCollection keysAndValuesReverseDo:[:index :value |
+	Transcript show:index; show:' '; showCr:value
+     ]  
+    "
 ! !
 
 !OrderedCollection methodsFor:'filling & replacing'!
@@ -1085,5 +1105,5 @@
 !OrderedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.38 1995-11-23 17:06:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.39 1995-12-05 12:38:23 chrisy Exp $'
 ! !