public boolean remove(K key)
    {
        KeyNode p = first;
        while(p != null){
            if(p.key.equals(key)){
                if(p == first)
                    first = first.next;
                else{
                    if(p.previous != null)
                        p.previous.next = p.next;
                    if(p.next != null)
                        p.next.previous = p.previous;
                }
                size--;
                return true;
            }
            p = p.next;
        }
        return false; 
    }