public void set(int key, int value) {
        if (size == 0){
            ListNode newNode = new ListNode(key,value);
            table.put(key, newNode);
            dummy.next = newNode;
            newNode.prev = dummy;
            tail = newNode;
            size ++;
        } else if (size < capacity){
            
            if (table.containsKey(key)){
                ListNode current = table.get(key);
                
                if (tail == current){
                    tail = current.prev;
                }
                
                ListNode tem = dummy.next;
                current.prev.next = current.next;
                dummy.next = current;
                current.prev = dummy;
                tem.prev = current;
                
                
            } else {
                ListNode current = new ListNode(key, value);
                table.put(key, current);
                
                ListNode tem = dummy.next;
                dummy.next = current;
                current.next = tem;
                current.prev = dummy;
                tem.prev = current;
                
                size ++;
            }
        } else if (size == capacity){
            if (table.containsKey(key)){
                ListNode current = table.get(key);
                
                if (tail == current){
                    tail = tail.prev;
                }
                
                ListNode tem = dummy.next;
                current.prev.next = current.next;
                dummy.next = current;
                current.prev = dummy;
                tem.prev = current;
            } else {
                ListNode current = new ListNode(key, value);
                
                table.put(key, current);
                
                ListNode tem = dummy.next;
                dummy.next = current;
                current.next = tem;
                current.prev = dummy;
                tem.prev = current;
                
                //remove node
                table.remove(tail.key);
                tail = tail.prev;
                tail.next = null;
                
            }
        }
    }