public void clear() { head = new DoubleLinkedNode(0, 0); tail = new DoubleLinkedNode(0, 0); head.next = tail; tail.pre = head; map = new HashMap<Integer, DoubleLinkedNode>(); }
public void add(int key, int val) { DoubleLinkedNode node = new DoubleLinkedNode(key, val); node.next = head.next; head.next.pre = node; head.next = node; node.pre = head; map.put(key, node); }