Beispiel #1
0
        public void AddToFront(int value)
        {
            IntegerNode newNode = new IntegerNode(value);

            newNode.Next = Head;
            Head         = newNode;
        }
Beispiel #2
0
        // This uses a HashSet and takes only O(n) time
        public void DeleteDupesFromBook(IntegerNode node)
        {
            HashSet <int> set      = new HashSet <int>();
            IntegerNode   previous = null;

            while (node != null)
            {
                if (set.Contains(node.Data))
                {
                    previous.Next = node.Next;
                }
                else
                {
                    set.Add(node.Data);
                    previous = node;
                }
                node = node.Next;
            }
        }
Beispiel #3
0
 public void SetNext(IntegerNode next)
 {
     Next = next;
 }