[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Composite Steppers
- To: <mark>, <xtech>
- Subject: Composite Steppers
- From: Eric Dean Tribble <tribble>
- Date: Wed, 25 Oct 89 00:42:37 PDT
Composite Steppers might be an elegant way of using several Steppers
in a loop. Your insistence that a composite Stepper have a sensible
value works fine (some kind of Tuple). I imagine the typical use will
just get values directly from the sub-Steppers rather than pulling
apart a composite value from the Composite Stepper. Thus:
tableSt = someTable ->stepper();
setSt = someSet ->stepper();
countSt = CountStepper(someTable ->lowerBound());
while (tableSt ->hasValue() && setSt ->hasValue()) {
resultVector ->store(countSt ->value(),
munge(setSt ->value(), tableSt ->value));
tableSt ->step();
setSt ->step();
countSt ->step();
}
I realize that I've ignored some necessary casts, but ignore that.
With CompositeSteppers:
tableSt = someTable ->stepper();
setSt = someSet ->stepper();
countSt = CountStepper(someTable ->lowerBound());
stepper = MultiStepper(tableSt, setSt, countSt);
while (stepper ->hasValue()) {
resultVector ->store(countSt ->value(),
munge(setSt ->value(), tableSt ->value));
stepper ->step();
}
It's certainly more readable. Not enough more useful in this example
to bother building it yet. We can build it if we run into harder
problems.
comments?
dean