public V remove(K key) {
        V val = get(key);

        if (val == null) {
            return null;
        }

        // removeAt(keys, currentIndex);
        // removeAt(values, currentIndex);

        checkEnoughCapacity(1);
        // Switch the chosen element and the last one
        exchangeWithLast(keys, currentIndex);
        exchangeWithLast(values, currentIndex);
        // Remove links to the chosen element
        keys[currentSize - 1] = null;
        values[currentSize - 1] = null;

        currentSize--;
        return val;
    }