package nmrsvd; public class ListGentle { private Node start, now, prev; public ListGentle () { now = null; start = null; prev = null; } public void add(Object x) { prev = now; if (start == null) { start = new Node (x, null); now = start; } else { Node T = new Node (x, now.link); now.link = T; now = T; } } public void remove() { if (isempty() || eol()) { return; } else { if (prev == null) { start = now.link; } else { prev.link = now.link; now = now.link; } } } public boolean isempty() { return start == null; } public Object current() { return now.data; } public void reset() { now = start; prev = null; } public boolean eol() { return now.link == null; } public void succ() { now = now.link; if (prev == null) prev = start; else prev = prev.link; } } class Node { Node link; Object data; /* The constructor copies in the data and the link to the given node * (which may be null). */ Node(Object d, Node n) { link = n; data = d; } }