1234567891011121314151617181920212223242526272829303132 |
- namespace Invercargill {
- private class PositionQuery<T> : BaseQuery<T, PositionItemPair<T>> {
- public PositionQuery(Enumerable<T> input) {
- this.input = input;
- }
- public override Tracker<PositionItemPair<T>> get_tracker() {
- return new PositionTracker<T>(input);
- }
- private class PositionTracker<T> : Tracker<PositionItemPair<T>> {
- private Tracker<T> base_tracker;
- private int position;
- public PositionTracker(Enumerable<T> input) {
- base_tracker = input.get_tracker();
- position = -1;
- }
- public override bool has_next() {
- return base_tracker.has_next();
- }
- public override PositionItemPair<T> get_next() {
- return new PositionItemPair<T>(++position, base_tracker.get_next());
- }
-
- }
- }
- }
|