Example #1
0
        public SllNode Find(int waldo)
        {
            SllNode runner = Head;

            while (runner.Next.Value != waldo)
            {
                runner = runner.Next;
            }
            return(runner.Next);
        }
Example #2
0
        public void PrintValues()
        {
            SllNode runner = Head;

            while (runner.Next != null)
            {
                System.Console.WriteLine(runner.Value);
                runner = runner.Next;
            }
        }
Example #3
0
        public void Remove(SllNode deadNode)
        {
            SllNode runner = Head;

            while (runner.Next.Value != deadNode.Value)
            {
                runner = runner.Next;
            }
            SllNode kill = runner.Next;

            // runner.Next.Next = null;
            runner.Next = runner.Next.Next;
            kill.Next   = null;
        }
Example #4
0
        public void Add(int value)
        {
            SllNode newNode = new SllNode(value);

            if (this.Head == null)
            {
                this.Head = newNode;
            }
            else
            {
                SllNode runner = Head;
                while (runner.Next != null)
                {
                    runner = runner.Next;
                }
                runner.Next = newNode;
            }
        }
Example #5
0
 public void Sll()
 {
     this.Head = null;
 }
Example #6
0
 public SllNode(int value)
 {
     Value = value;
     Next  = null;
 }