KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > lists > GeneralArray1


1 // Copyright (c) 2001, 2002 Per M.A. Bothner and Brainfood Inc.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.lists;
5
6 public class GeneralArray1 extends GeneralArray implements Sequence
7 {
8   public int createPos(int index, boolean isAfter)
9   {
10     return (index << 1) | (isAfter ? 1 : 0);
11   }
12
13   protected int nextIndex(int ipos)
14   {
15     return ipos == -1 ? size() : ipos >>> 1;
16   }
17
18   public void consumePosRange(int iposStart, int iposEnd, Consumer out)
19   {
20     if (out.ignoring())
21       return;
22     int it = iposStart;
23     while (! equals(it, iposEnd))
24       {
25     if (! hasNext(it))
26       throw new RuntimeException JavaDoc();
27         base.consume(offset + strides[0] * (it >>> 1), 1, out);
28         it = nextPos(it);
29       }
30   }
31 }
32
33
Popular Tags