# HG changeset patch # User ca # Date 826279331 -3600 # Node ID def6e50a2d1346f569688585e953e5a20aa8d5ee # Parent 6df9414b354f4092909552a9db721e2dbf7dd70b oops - keysAndValuesDo was wrong, iff elements have been removed upFront recently diff -r 6df9414b354f -r def6e50a2d13 OrdColl.st --- a/OrdColl.st Thu Mar 07 19:42:16 1996 +0100 +++ b/OrdColl.st Fri Mar 08 11:02:11 1996 +0100 @@ -622,19 +622,32 @@ passing both index and element as arguments." |start "{ Class:SmallInteger }" - stop "{ Class:SmallInteger }" | + stop "{ Class:SmallInteger }" + idx "{ Class:SmallInteger }" | stop := lastIndex. start := firstIndex. + idx := 1. start to:stop do:[:index | - aTwoArgBlock value:index value:(contentsArray at:index) + aTwoArgBlock value:idx value:(contentsArray at:index). + idx := idx + 1. ] " #(10 20 30 40) asOrderedCollection keysAndValuesDo:[:index :value | - Transcript show:index; show:' '; showCr:value + Transcript show:index; show:' '; showCr:value ] " + " + |oc| + + oc := #(10 20 30 40 50 60 70 80) asOrderedCollection. + oc removeFirst; removeFirst. + oc keysAndValuesDo:[:index :value | + Transcript show:index; show:' '; showCr:value + ] + " + ! keysAndValuesReverseDo:aTwoArgBlock @@ -642,17 +655,30 @@ passing both index and element as arguments." |start "{ Class:SmallInteger }" - stop "{ Class:SmallInteger }" | + stop "{ Class:SmallInteger }" + idx "{ Class:SmallInteger }"| stop := lastIndex. start := firstIndex. + idx := (stop - start + 1). stop to:start by: -1 do:[:index | - aTwoArgBlock value:index value:(contentsArray at:index) + aTwoArgBlock value:idx value:(contentsArray at:index). + idx := idx - 1. ] " #(10 20 30 40) asOrderedCollection keysAndValuesReverseDo:[:index :value | - Transcript show:index; show:' '; showCr:value + Transcript show:index; show:' '; showCr:value + ] + " + + " + |oc| + + oc := #(10 20 30 40 50 60 70 80) asOrderedCollection. + oc removeFirst; removeFirst. + oc keysAndValuesReverseDo:[:index :value | + Transcript show:index; show:' '; showCr:value ] " ! @@ -1117,5 +1143,5 @@ !OrderedCollection class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.40 1996-03-06 15:03:55 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.41 1996-03-08 10:02:11 ca Exp $' ! ! diff -r 6df9414b354f -r def6e50a2d13 OrderedCollection.st --- a/OrderedCollection.st Thu Mar 07 19:42:16 1996 +0100 +++ b/OrderedCollection.st Fri Mar 08 11:02:11 1996 +0100 @@ -622,19 +622,32 @@ passing both index and element as arguments." |start "{ Class:SmallInteger }" - stop "{ Class:SmallInteger }" | + stop "{ Class:SmallInteger }" + idx "{ Class:SmallInteger }" | stop := lastIndex. start := firstIndex. + idx := 1. start to:stop do:[:index | - aTwoArgBlock value:index value:(contentsArray at:index) + aTwoArgBlock value:idx value:(contentsArray at:index). + idx := idx + 1. ] " #(10 20 30 40) asOrderedCollection keysAndValuesDo:[:index :value | - Transcript show:index; show:' '; showCr:value + Transcript show:index; show:' '; showCr:value ] " + " + |oc| + + oc := #(10 20 30 40 50 60 70 80) asOrderedCollection. + oc removeFirst; removeFirst. + oc keysAndValuesDo:[:index :value | + Transcript show:index; show:' '; showCr:value + ] + " + ! keysAndValuesReverseDo:aTwoArgBlock @@ -642,17 +655,30 @@ passing both index and element as arguments." |start "{ Class:SmallInteger }" - stop "{ Class:SmallInteger }" | + stop "{ Class:SmallInteger }" + idx "{ Class:SmallInteger }"| stop := lastIndex. start := firstIndex. + idx := (stop - start + 1). stop to:start by: -1 do:[:index | - aTwoArgBlock value:index value:(contentsArray at:index) + aTwoArgBlock value:idx value:(contentsArray at:index). + idx := idx - 1. ] " #(10 20 30 40) asOrderedCollection keysAndValuesReverseDo:[:index :value | - Transcript show:index; show:' '; showCr:value + Transcript show:index; show:' '; showCr:value + ] + " + + " + |oc| + + oc := #(10 20 30 40 50 60 70 80) asOrderedCollection. + oc removeFirst; removeFirst. + oc keysAndValuesReverseDo:[:index :value | + Transcript show:index; show:' '; showCr:value ] " ! @@ -1117,5 +1143,5 @@ !OrderedCollection class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.40 1996-03-06 15:03:55 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.41 1996-03-08 10:02:11 ca Exp $' ! !