01: // Copyright (c) 2003 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.lists;
05:
06: /** A SeqPosition for sequences that need more than a Pos int for a position.
07: * For such sequences, a Pos int is an index into a PositionManager,
08: * which manages a table of ExtPositions, which may contain more state
09: * than a regular SeqPosition does.
10: */
11:
12: public class ExtPosition extends SeqPosition {
13: /** Index into PositionManager.positions, if >= 0.
14: * This is used if we need a single Pos integer for this position. */
15: int position = -1;
16:
17: public int getPos() {
18: if (position < 0)
19: position = PositionManager.manager.register(this );
20: return position;
21: }
22:
23: public void setPos(AbstractSequence seq, int ipos) {
24: throw seq.unsupported("setPos");
25: }
26:
27: public final boolean isAfter() {
28: return (ipos & 1) != 0;
29: }
30:
31: public void release() {
32: if (position >= 0)
33: PositionManager.manager.release(position);
34: sequence = null;
35: }
36: }
|