01: // Copyright (c) 2003 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: /** Abstract helper class for Sequences that use an ExtPosition.
07: * That is sequences where it is inefficient to represent a position
08: * just using a Pos int.
09: */
10:
11: public abstract class ExtSequence extends AbstractSequence {
12: public int copyPos(int ipos) {
13: if (ipos <= 0)
14: return ipos;
15: return PositionManager.manager.register(PositionManager
16: .getPositionObject(ipos).copy());
17: }
18:
19: protected void releasePos(int ipos) {
20: if (ipos > 0)
21: PositionManager.manager.release(ipos);
22: }
23:
24: protected boolean isAfterPos(int ipos) {
25: if (ipos <= 0)
26: return ipos < 0;
27: return (PositionManager.getPositionObject(ipos).ipos & 1) != 0;
28: }
29:
30: protected int nextIndex(int ipos) {
31: return ipos == -1 ? size() : ipos == 0 ? 0 : PositionManager
32: .getPositionObject(ipos).nextIndex();
33: }
34: }
|