public Node <T> Insert(Node <T> p, T info) { Node <T> q = new Node <T>(info); if (p == null) { q.SetNext(first); first = q; } else { q.SetNext(p.GetNext()); p.SetNext(q); } return(q); }
private static Node <int> AttachNode(Node <int> h, Node <int> t, Node <int> temp, Node <int> p) { if (temp == null) { p.SetNext(t); } else { if (p == null) { t.SetNext(temp); h = t; } else { t.SetNext(temp); p.SetNext(t); } } return(h); }
public Node <T> Remove(Node <T> p) { if (first == p) { first = p.GetNext(); return(first); } else { Node <T> prev = first; while (prev.GetNext() != p) { prev = prev.GetNext(); } prev.SetNext(p.GetNext()); return(prev.GetNext()); } }