Reading material

pages 114-121.

Additional material

Container.java
RankedSequence.java
BoundaryViolationException.java

public static RankedSequence removeDuplicates(RankedSequence sequence) {
    for (int i = 0; i < sequence.size(); i++) {
    /* the first i elements of sequence contain no duplicates and
       sequence contains the same elements (possibly with some duplicates
       removed) as the original sequence */
        Object first = sequence.ElemAtRank(i);
        int j = i + 1
        while (j < sequence.size()) {
        /* the (i+1)th to (j-1)th element of sequence are different from
           the ith element of sequence */
            Object second = sequence.ElemAtRank(j);
            if (first.equals(second)) {
                sequence.removeElemAtRank(j);
            } else {
                j++;
            }
        }
    }
    return sequence;
}

Implementation of a ranked sequence with an array in PostScript and PDF

ArrayRankedSequence.java
RankedSequenceFullException.java
ArrayRankedSequenceTester.java

After execution of the code fragment

ArrayRankedSequence s = new ArrayRankedSequence(4);
s.insertElementAtRank(0, new Integer(2));
s.insertElementAtRank(0, new Integer(1));
s.insertElementAtRank(2, new Integer(3));
the ArrayRankedSequence object s can be depicted as follows.

java.util.Vector
VectorRankedSequence.java

NodeRankedSequence.java