Esempio n. 1
0
        public void InsertFirst(Object n)
        {
            DoubleNode current = new DoubleNode(n);

            current.Blink = header;
            header.Flink  = current;
            count++;
        }
Esempio n. 2
0
        public void Remove(Object n)
        {
            DoubleNode p = FindPrevious(n);

            if (!(p.Flink == null))
            {
                p.Flink = p.Flink.Flink;
                count--;
            }
        }
Esempio n. 3
0
        public void Insert(Object n1, Object n2)
        {
            DoubleNode current = new DoubleNode();
            DoubleNode newnode = new DoubleNode(n1);

            current       = Find(n2);
            newnode.Flink = current.Flink;
            current.Flink = newnode;
            count++;
        }
Esempio n. 4
0
        private DoubleNode FindPrevious(Object n)
        {
            DoubleNode current = header;

            while (!(current.Blink == null) && current.Blink.Element != n)
            {
                current = current.Blink;
            }
            return(current);
        }
Esempio n. 5
0
        public void Insert(Object newItem, Object after)
        {
            DoubleNode current = new DoubleNode();
            DoubleNode newNode = new DoubleNode(newItem);

            current       = Find(after);
            newNode.Flink = current.Flink;
            newNode.Blink = current;
            current.Flink = newNode;
        }
Esempio n. 6
0
        private DoubleNode Find(Object n)
        {
            DoubleNode current = new DoubleNode();

            current = header.Flink;
            while (current.Element != n)
            {
                current = current.Flink;
            }
            return(current);
        }
Esempio n. 7
0
        public void PrintList()
        {
            DoubleNode current = new DoubleNode();

            current = header;
            while (!(current.Flink.Element.ToString() == "header"))
            {
                Console.WriteLine(current.Flink.Element);
                current = current.Flink;
            }
        }
Esempio n. 8
0
        public void PrintReverse()
        {
            DoubleNode current = new DoubleNode();

            current = FindLast();
            while (!(current.Blink == null))
            {
                Console.WriteLine(current.Element);
                current = current.Blink;
            }
        }
Esempio n. 9
0
        private DoubleNode FindLast()
        {
            DoubleNode current = new DoubleNode();

            current = header;
            while (!(current.Flink == null))
            {
                current = current.Flink;
            }
            return(current);
        }
Esempio n. 10
0
        public void Remove(Object n)
        {
            DoubleNode p = Find(n);

            if (!(p.Flink == null))
            {
                p.Blink.Flink = p.Flink;
                p.Flink.Blink = p.Blink;
                p.Flink       = null;
                p.Blink       = null;
            }
        }
Esempio n. 11
0
        public DoubleNode Move(int n)
        {
            DoubleNode current = header.Flink;
            DoubleNode temp;

            for (int i = 0; i <= n; i++)
            {
                current = current.Flink;
            }
            if (current.Element.ToString() == "header")
            {
                current = current.Flink;
            }
            temp = current;
            return(temp);
        }
Esempio n. 12
0
 public DoubleNode(Object theElement)
 {
     Element = theElement;
     Flink   = null;
     Blink   = null;
 }
Esempio n. 13
0
 public DoubleNode()
 {
     Element = null; Flink = null;
     Blink   = null;
 }
Esempio n. 14
0
 public CircularLinkedList()
 {
     count        = 0;
     header       = new DoubleNode("header");
     header.Flink = header;
 }
Esempio n. 15
0
 public DoublyLinkedList()
 {
     header = new DoubleNode("header");
 }