KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > lists > ExtSequence


1 // Copyright (c) 2003 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 /** Abstract helper class for Sequences that use an ExtPosition.
7  * That is sequences where it is inefficient to represent a position
8  * just using a Pos int.
9  */

10
11 public abstract class ExtSequence extends AbstractSequence
12 {
13   public int copyPos (int ipos)
14   {
15     if (ipos <= 0)
16       return ipos;
17     return PositionManager.manager.register(PositionManager.getPositionObject(ipos).copy());
18   }
19
20   protected void releasePos(int ipos)
21   {
22     if (ipos > 0)
23       PositionManager.manager.release(ipos);
24   }
25
26   protected boolean isAfterPos (int ipos)
27   {
28     if (ipos <= 0)
29       return ipos < 0;
30     return (PositionManager.getPositionObject(ipos).ipos & 1) != 0;
31   }
32
33   protected int nextIndex(int ipos)
34   {
35     return ipos == -1 ? size() : ipos == 0 ? 0
36       : PositionManager.getPositionObject(ipos).nextIndex();
37   }
38 }
39
Popular Tags