Ejemplo n.º 1
0
        public bool DeleteNode(MyMapNode <K, V> DeleteNode)
        {
            MyMapNode <K, V> temp = Head;

            if (!IsEmpty())
            {
                if (DeleteNode.key.Equals(Head.key))
                {
                    Pop();
                    return(true);
                }
                if (DeleteNode.key.Equals(Tail.key))
                {
                    PopLast();
                    return(true);
                }
                while (temp != null)
                {
                    if (temp.next != null && temp.next.key.Equals(DeleteNode.key))
                    {
                        temp.next = DeleteNode.next;
                        return(true);
                    }
                    temp = temp.next;
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool DeleteNode(MyMapNode <K, V> DeleteNode)
        {
            MyMapNode <K, V> temp = head;

            if (!IsEmpty())
            {
                //If removing node is first
                if (DeleteNode.key.Equals(head.key))
                {
                    Pop();
                    return(true);
                }
                //If removing node is last
                if (DeleteNode.key.Equals(tail.key))
                {
                    PopLast();
                    return(true);
                }
                while (temp != null)
                {
                    //If removing node rather than first and last
                    if (temp.next != null && temp.next.key.Equals(DeleteNode.key))
                    {
                        temp.next = DeleteNode.next;
                        return(true);
                    }
                    temp = temp.next;
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public MyMapNode <K, V> Pop()
        {
            MyMapNode <K, V> temp = Head;

            if (Head != null)
            {
                Head = Head.next;
            }
            return(temp);
        }
Ejemplo n.º 4
0
        public MyMapNode <K, V> Pop()
        {
            //Temp assign to the first node
            MyMapNode <K, V> temp = head;

            if (head != null)
            {
                //Moving head to next Node and remove first node
                head = head.next;
            }
            return(temp);
        }
Ejemplo n.º 5
0
 public void Append(MyMapNode <K, V> node)
 {
     if (Head == null && Tail == null)
     {
         Head = node;
         Tail = node;
     }
     else
     {
         Tail.next = node;
         Tail      = node;
     }
 }
Ejemplo n.º 6
0
        internal MyMapNode <K, V> Search(K key)
        {
            MyMapNode <K, V> temp = Head;

            while (temp != null)
            {
                if (temp.key.Equals(key))
                {
                    return(temp);
                }
                ;
                temp = temp.next;
            }
            return(null);
        }
Ejemplo n.º 7
0
 public void Append(MyMapNode <K, V> node)
 {
     //Check node is present or not
     if (head == null && tail == null)
     {
         head = node;
         tail = node;
     }
     else
     {
         //If present then node added from the end
         tail.next = node;
         tail      = node;
     }
 }
Ejemplo n.º 8
0
        public MyMapNode <K, V> PopLast()
        {
            MyMapNode <K, V> TailTemp = Tail;

            if (!IsEmpty())
            {
                MyMapNode <K, V> temp = Head;
                while (temp.next != Tail)
                {
                    temp = temp.next;
                }
                temp.next = null;
                Tail      = temp;
            }
            return(TailTemp);
        }
Ejemplo n.º 9
0
        public MyMapNode <K, V> Search(K key)
        {
            //Head will assigen as temp
            MyMapNode <K, V> temp = head;

            while (temp != null)
            {
                if (temp.key.Equals(key))
                {
                    return(temp);
                }
                ;
                temp = temp.next;
            }
            return(null);
        }
Ejemplo n.º 10
0
        public MyMapNode <K, V> PopLast()
        {
            MyMapNode <K, V> tailTemp = tail;

            if (!IsEmpty())
            {
                //Head is assign as temp
                MyMapNode <K, V> temp = head;
                while (temp.next != tail)
                {
                    //Traversing till tail
                    temp = temp.next;
                }

                temp.next = null;
                tail      = temp;
            }
            return(tailTemp);
        }
Ejemplo n.º 11
0
 public MyMapNode(K key, V value)
 {
     this.key   = key;
     this.value = value;
     next       = null;
 }
Ejemplo n.º 12
0
 public LinkedList()
 {
     Head = null;
     Tail = null;
 }
Ejemplo n.º 13
0
 public LinkedList()
 {
     head = null;
     tail = null;
 }