public MyMapNode delete()
        {
            MyMapNode tempNode1 = head;

            this.tail = tempNode1;
            return(tail);
        }
        public MyMapNode pop()
        {
            MyMapNode tempNode = this.head;

            this.head = head.getNext();
            return(tempNode);
        }
Beispiel #3
0
        public void remove(string key)
        {
            int          index        = this.getBucketIndex(key);
            MyLinkedList myLinkedList = this.myBucketArray[index];
            MyMapNode    myMapNode    = (MyMapNode)myLinkedList.search(key);

            myLinkedList.delete();
        }
Beispiel #4
0
        public int get(string key)
        {
            int          index        = this.getBucketIndex(key);
            MyLinkedList myLinkedList = this.myBucketArray[index];

            if (myLinkedList == null)
            {
                return(0);
            }
            MyMapNode myMapNode = (MyMapNode)myLinkedList.search(key);

            return((myMapNode == null) ? 0 : myMapNode.getValue());
        }
        public MyMapNode popLast()
        {
            MyMapNode tempNode = head;

            while (!tempNode.getNext().Equals(tail))
            {
                tempNode = tempNode.getNext();
            }
            this.tail = tempNode;
            tempNode  = tail.getNext();
            tempNode  = null;
            return(tempNode);
        }
Beispiel #6
0
        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);
            }
        }
        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);
        }
 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);
     }
 }
        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 #10
0
        public void add(string key, int value)
        {
            int          index        = this.getBucketIndex(key);
            MyLinkedList myLinkedList = this.myBucketArray[index];

            if (myLinkedList == null)
            {
                myLinkedList = new MyLinkedList();
                this.myBucketArray[index] = myLinkedList;
            }
            MyMapNode myMapNode = (MyMapNode)myLinkedList.search(key);

            if (myMapNode == null)
            {
                myMapNode = new MyMapNode(key, value);
                myLinkedList.append(myMapNode);
            }
            else
            {
                myMapNode.setValue(value);
            }
        }
Beispiel #11
0
 public void setNext(MyMapNode next)
 {
     this.next = (MyMapNode)next;
 }
Beispiel #12
0
 public MyMapNode(string key, int value)
 {
     this.key   = key;
     this.value = value;
     next       = null;
 }
Beispiel #13
0
        public int get(string key)
        {
            MyMapNode myMapNode = (MyMapNode)this.myLinkedList.search(key);

            return((myMapNode == null) ? 0 : myMapNode.getValue());
        }
 public void insert(MyMapNode myNode, MyMapNode newNode)
 {
     this.head.setNext(myNode);
     myNode.setNext(newNode);
 }
 public MyLinkedList()
 {
     this.head = null;
     this.tail = null;
 }