package GCB; /* Define a linked list entry the entry contains two pointers the next entry in the list the prior entry in the list the entry also contains a pointer to the list head (not referenceable) setHead(h) sets the pointer to the list head setNext(e) sets link to next list entry getNext() returns link to next list entry setPrior(e) set link to prior list entry getPrior() returns link to next list entry clean() removes a vestiges of being on a list finalize() prints a message if a list entry is garbage collected */ public class ListEntry { static final String CODE_FILE = "ListEntry"; static final int CODE_REVISION = 2; private Object head; // head of the linked list private ListEntry next, // next entry in the list prior; // prior entry in the list public ListEntry() { // constructor for list entry head = null; // not on a linked list next = prior = null; // chain is empty } public void setHead(Object h) {head = h;} // set the list head (for debug) public Object getHead(){return head;} // get the list head public void setNext(ListEntry e) {next = e;} // set the next entry in the list public ListEntry getNext() {return next;} // get the next entry in the list public void setPrior(ListEntry e) {prior = e;} // set the prior entry in the list public ListEntry getPrior() {return prior;} // get the prior entry in the list public void clean() { // clean up after removal from a list if(head==null) { System.out.println(CODE_FILE+ " attempt to clean a list entry that was not on a list!"); Thread.dumpStack(); } prior = next = null; head = null; } public void finalize() { // clean up before destruction of object if(head!=null) { System.out.println(CODE_FILE+ " attempt to release a linked list entry!"); System.out.println(CODE_FILE+" head="+head.toString()); System.out.println(CODE_FILE+" head="+head.getClass()); Thread.dumpStack(); } } }