public T set(int i, T value) {
        T oldElement = elements.get(i);
        elements.set(i,value); // update list
        super.remove(oldElement); // now update the set: remove/add
        super.add(value);
        return oldElement;
    }
Replace an existing value with a new value; updates the element
 list and the hash table, but not the key as that has not changed.
runtime/Java/src/org/antlr/v4/runtime/misc/OrderedHashSet.java