Reading material

pages 122-136.

Additional material

Position.java

PositionalSequence s = new DLPositionalSequence();
Position p1 = s.insertFirst(new Integer(8));
Position p2 = s.insertAfter(p1, new Integer(5));
Position p3 = s.insertBefore(p2, new Integer(3));
Position p4 = s.insertFirst(new Integer(9));
Position p5 = s.before(p3);
Position p6 = s.last();
Object e1   = s.remove(p4);
s.swap(p1, p2);
Object e1   = s.replace(p3, new Integer(7));
Position p7 = s.insertAfter(first(), new Integer(2));

Implementation of a positional sequence with a doubly linked list in PostScript and PDF

NSNode.java

Why do we need containers in NSNode?

PositionalSequence s1 = new DLPositionalSequence();
PositionalSequence s2 = new DLPositionalSequence();
Position p1 = s1.insertFirst(new Integer(8));
Position p2 = s2.insertFirst(new Integer(4));
s1.swap(p1, p2); /* p1 is part of s1 but p2 isn't! */

After execution of the code fragment

PositionalSequence s = new DLPositionalSequence();
Position p1 = s.insertFirst(new Integer(1));
Position p2 = s.insertLast(new Integer(2));
the PositionalSequence object s can be depicted as follows.

Sequence.java

Bubble-sort in PostScript and PDF