// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import nullfree.linkedlist.HeadAndTail;
import nullfree.linkedlist.Node;
import nullfree.linkedlist.NodeFactory;
import nullfree.linkedlist.polymorph.PolymorphNodeFactory;
import nullfree.linkedlist.std.LinkedList;

public class Test {
    public static void main(String[] args) {
        NodeFactory<String> nf = new PolymorphNodeFactory<String>();
        HeadAndTail<String> hat = nf.createFirstNode("A");
        Node<String> n = hat.getHead();
        n = n.insertValue("B", hat);
        n = n.insertValue("C", hat);
        n = n.insertValue("D", hat);
        n = hat.getHead();
        System.out.println("low level:");
    	System.out.println(n.getValue());
        while(n.hasNext()) {
        	n = n.getNext();
        	System.out.println(n.getValue());
        };
        LinkedList<String> lst = new LinkedList<String>("A");
        lst.add("B");
        lst.add("C");
        lst.add("D");
        System.out.println("high level (new for):");
        for(String s : lst) {
        	System.out.println(s);
        }
        System.out.println("high level (old for):");
        for(int i = 0; i < lst.size(); i++) {
        	System.out.println(lst.get(i));
        }
    }
}
