sclass TokenIndexedList extends RandomAccessAbstractList { new Map index; // first occurrence of token new L list; sclass Token { S s; Token prevSame, nextSame; } public S get(int i) { ret list.get(i).s; } public int size() { ret list.size(); } public void set(int i, S s) { Token t = list.get(i); if (eq(t.s, s)) ret; t.prevSame.nextSame = t.nextSame; t.nextSame.prevSame = t.nextSame; // ... } }