01: // Copyright (c) 2001, 2002 Per M.A. Bothner and Brainfood Inc.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.lists;
05:
06: public class GeneralArray1 extends GeneralArray implements Sequence {
07: public int createPos(int index, boolean isAfter) {
08: return (index << 1) | (isAfter ? 1 : 0);
09: }
10:
11: protected int nextIndex(int ipos) {
12: return ipos == -1 ? size() : ipos >>> 1;
13: }
14:
15: public void consumePosRange(int iposStart, int iposEnd, Consumer out) {
16: if (out.ignoring())
17: return;
18: int it = iposStart;
19: while (!equals(it, iposEnd)) {
20: if (!hasNext(it))
21: throw new RuntimeException();
22: base.consume(offset + strides[0] * (it >>> 1), 1, out);
23: it = nextPos(it);
24: }
25: }
26: }
|