// Path: src/main/java/rogeriogentil/data/structures/chapter09/Entry.java
// public interface Entry<K, V> {
// 
//    /**
//     * Returns the key stored in this entry
//     *
//     * @return
//     */
//    K getKey();
// 
//    /**
//     * Returns the value stored in this entry
//     *
//     * @return
//     */
//    V getvalue();
// }


import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
import rogeriogentil.data.structures.chapter09.Entry;
        int index = this.findIndex(key);

        if (index == -1) {
            table.add(new MapEntry<>(key, value));
            return null;        // not found
        } else {
            V old = table.get(index).getvalue();
            table.get(index).setValue(value);
            return old;
        }
    }

    /**
     * Removes the entry with the specified key (if any) and returns its value.
     *
     * @param key
     * @return
     */
    @Override
    public V remove(K key) {
        int index = this.findIndex(key);
        int n = table.size();

        if (index == -1) {
            return null;        // not found
        }

        V value = table.get(index).getvalue();

        if (index != n - 1) {
// Path: src/main/java/rogeriogentil/data/structures/chapter09/Entry.java
// public interface Entry<K, V> {
// 
//    /**
//     * Returns the key stored in this entry
//     *
//     * @return
//     */
//    K getKey();
// 
//    /**
//     * Returns the value stored in this entry
//     *
//     * @return
//     */
//    V getvalue();
// }


// Path: src/main/java/rogeriogentil/data/structures/chapter10/UnsortedTableMap.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
import rogeriogentil.data.structures.chapter09.Entry;

        int index = this.findIndex(key);

        if (index == -1) {
            table.add(new MapEntry<>(key, value));
            return null;        // not found
        } else {
            V old = table.get(index).getvalue();
            table.get(index).setValue(value);
            return old;
        }
    }

    /**
     * Removes the entry with the specified key (if any) and returns its value.
     *
     * @param key
     * @return
     */
    @Override
    public V remove(K key) {
        int index = this.findIndex(key);
        int n = table.size();

        if (index == -1) {
            return null;        // not found
        }

        V value = table.get(index).getvalue();

        if (index != n - 1) {
            table.set(index, table.get(n - 1)); // relocate last entry to ’hole’ created by removal