Beispiel #1
0
        public MyMapNode pop()
        {
            MyMapNode tempNode = this.head;

            this.head = head.getNext();
            return(tempNode);
        }
Beispiel #2
0
        public MyMapNode popLast()
        {
            MyMapNode tempNode = head;

            while (!tempNode.getNext().Equals(tail))
            {
                tempNode = tempNode.getNext();
            }
            this.tail = tempNode;
            tempNode  = tail.getNext();
            tempNode  = null;
            return(tempNode);
        }
        public void add(string key, int value)
        {
            MyMapNode myMapNode = (MyMapNode)this.myLinkedList.search(key);

            if (myMapNode == null)
            {
                myMapNode = new MyMapNode(key, value);
                this.myLinkedList.append(myMapNode);
            }
            else
            {
                myMapNode.setValue(value);
            }
        }
Beispiel #4
0
        public MyMapNode search(string key)
        {
            MyMapNode tempNode = head;

            while (tempNode != null && tempNode.getNext() != null)
            {
                if (tempNode.getKey().Equals(key))
                {
                    return(tempNode);
                }
                tempNode = tempNode.getNext();
            }
            return(null);
        }
Beispiel #5
0
 public void append(MyMapNode newNode)
 {
     if (this.head == null)
     {
         this.head = newNode;
     }
     if (this.tail == null)
     {
         this.tail = newNode;
     }
     else
     {
         MyMapNode tempNode = this.tail;
         this.tail = newNode;
         tempNode.setNext(newNode);
     }
 }
Beispiel #6
0
        public void add(MyMapNode newNode)
        {
            if (this.tail == null)
            {
                this.tail = newNode;
            }

            if (this.head == null)
            {
                this.head = newNode;
            }
            else
            {
                MyMapNode tempNode = this.head;
                this.head = newNode;
                this.head.setNext(tempNode);
            }
        }
Beispiel #7
0
 public void insert(MyMapNode myNode, MyMapNode newNode)
 {
     this.head.setNext(myNode);
     myNode.setNext(newNode);
 }
Beispiel #8
0
 public MyLinkedList()
 {
     this.head = null;
     this.tail = null;
 }
 public void setNext(MyMapNode next)
 {
     this.next = (MyMapNode)next;
 }
 public MyMapNode(string key, int value)
 {
     this.key   = key;
     this.value = value;
     next       = null;
 }
        public int get(string key)
        {
            MyMapNode myMapNode = (MyMapNode)this.myLinkedList.search(key);

            return((myMapNode == null) ? 0 : myMapNode.getValue());
        }