EP05 - erratas

Re: EP05 - erratas

por José Coelho de Pina -
Número de respostas: 0

Oi Guilherme,

no if, acredito que deveria ser val == null para entrar no delete?

Você tem razão. olho roxo
Muito obrigado por avisar.
O código de put deveria ser:

    /**
     * Inserts the key-value pair into the symbol table, overwriting the old value
     * with the new value if the key is already in the symbol table.
     * If the value is {@code null}, this effectively deletes the key from the symbol table.
     * @param key the key
     * @param val the value
     * @throws IllegalArgumentException if {@code key} is {@code null}
     */
    public void put(String key, Value val) {
        if (key == null) {
            throw new IllegalArgumentException("calls put() with null key"); 
        }
        if (val == null) { // MAC0323
            delete(key);
        }    
        if (!contains(key)) n++;
        root = put(root, key, val, 0);
    }