Пример #1
0
        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;
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
 public List()
 {
     _root = null;
 }