public MyMapNode pop() { MyMapNode tempNode = this.head; this.head = head.getNext(); return(tempNode); }
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); } }
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); } }
public void insert(MyMapNode myNode, MyMapNode newNode) { this.head.setNext(myNode); myNode.setNext(newNode); }
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()); }