package OrederedLists;
public class Link {
public String name; public Link next() { return nxt;} public Link prev() { return prv;}
protected Link nxt, prv; protected Head myhead; protected int ev_time = 0;
public void out() {
if (this == null) System.out.println("can't take null out");
else { if (myhead.sz == 1) myhead.fst = myhead.lst = null;
else { prv.nxt = nxt; nxt.prv = prv;
if (myhead.fst == this) myhead.fst = this.nxt;
if (myhead.lst == this) myhead.lst = this.prv; }
myhead.sz--; myhead = null; nxt = prv = null;
}
} // end out
protected void before (Link lk) { // this Link inserted before lk
if (this == null || lk == null) System.out.println("can't put null before");
else { nxt = lk; prv = lk.prv; lk.prv.nxt = this; lk.prv = this;
myhead = lk.myhead;
if (myhead.fst == lk) myhead.fst = this; myhead.sz++;
}
} // end before
Link (String n, int t) { name = n; ev_time = t; }
Link (int t) { name = "no_name"; ev_time = t; }
Link (String n) { name = n; System.out.println("Created " + name); }
Link () {name = "no-name"; }
} // end class Link
Previous slide | Next slide | Back to first slide | View graphic version |