예제 #1
0
 public void Clear()
 {
     Head = null;
     //while (Head != null)
     //{
     //    Head = Head.Next;
     //}
     cnt = 0;
 }
예제 #2
0
        public void Print()
        {
            DequeNode <T> tempNode = Head;

            while (tempNode != null)
            {
                Console.WriteLine(tempNode.data);
                tempNode = tempNode.Next;
            }
        }
예제 #3
0
        public DequeNode <T> DequeueLeft()
        {
            if (Head == null)
            {
                return(null);
            }

            DequeNode <T> DeqNode = Head;

            Head = Head.Next;

            cnt--;
            return(DeqNode);
        }
예제 #4
0
        public DequeNode <T> DequeueRight()
        {
            if (Head == null)
            {
                return(null);
            }

            DequeNode <T> DeqNode = Tail;

            Tail      = Tail.Pre;
            Tail.Next = null;

            cnt--;
            return(DeqNode);
        }
예제 #5
0
        public bool Contains(T Data)
        {
            bool          result   = false;
            DequeNode <T> tempNode = Head;

            while (tempNode != null)
            {
                if (Compare(Data, tempNode.data))
                {
                    result = true;
                    break;
                }
                else
                {
                    tempNode = tempNode.Next;
                }
            }

            return(result);
        }
예제 #6
0
        public void EnqueueLeft(T a_data)
        {
            if (Head == null)
            {
                this.Head = new DequeNode <T>();

                this.Head.data = a_data;
                this.Head.Next = null;
                Tail           = Head;
            }
            else
            {
                DequeNode <T> newNode = new DequeNode <T>();
                newNode.data = a_data;

                newNode.Next = Head;
                Head         = newNode;
            }

            cnt++;
        }
예제 #7
0
        public void EnqueueRight(T a_data)
        {
            if (Head == null)
            {
                this.Head = new DequeNode <T>();

                this.Head.data = a_data;
                this.Head.Next = null;
                Tail           = Head;
            }
            else
            {
                DequeNode <T> newNode = new DequeNode <T>();
                newNode.data = a_data;
                DequeNode <T> TempNode = Tail;

                Tail.Next   = newNode;
                Tail        = newNode;
                newNode.Pre = TempNode;
            }

            cnt++;
        }