package ga050426;

class Relocation{
	int loc, seg, ref;
	String type;
	Relocation prec, next;
	Relocation(int loc, int seg, int ref, String type, Relocation prec, Relocation next){
		this.loc=loc;
		this.seg=seg;
		this.ref=ref;
		this.type=type;
		this.prec=prec;
		this.next=next;
	}
}

public class Relocations {
	Relocation head, tail;
	
	public void enter(int loc, int seg, int ref, String type){
		if (tail != null)
			tail = tail.next = new Relocation(loc, seg, ref, type, tail, null);
		else
			tail = head = new Relocation(loc, seg, ref, type, tail, null);
	}
	Relocations(){}
	public static Relocations instance = new Relocations();
	public String toString() {
		StringBuffer buf = new StringBuffer(String
				.format("#Relocations (dec)%n"));
		for (Relocation cur = head; cur != null; cur = cur.next) {
			buf.append(String.format(" %d  %d  %d  %s %n", cur.loc, cur.seg, cur.ref, cur.type));
		}
		return new String(buf);
	}
}

