public void Insert(Object addMe) { Node toAttach = new Node(); // Construct the new node toAttach.Data = addMe; if (_root == null) { _root = toAttach; } else { Node rest = _root; _root = toAttach; _root.Next = rest; } }
public void Delete(Object deleteMe) { if (deleteMe.ToString() == _root.Data.ToString()) { _root = _root.Next; return; } Node current = _root; while (current.Next != null) { if (current.Next.Data.ToString() == deleteMe.ToString()) { current.Next = current.Next.Next; return; } current = current.Next; } }
public List() { _root = null; }