/** * Inserts <code>obj</code> to be mapped to key <code>key<code>. All values * mapped to keys <code>key</code> and on will be mapped to a key greater in * one.</code></code> * * @param obj Object to be inserted into the map. * @param key The insertion key */ public void insertObject(Object obj, int key) { // moving all elements mapped to key through the maximal key // to be mapped to a key greater in 1. int max = VHashService.getMaxKey(this); int[] keysInRange = VHashService.getIndicesInRange(key, max, this); for (int i = keysInRange.length - 1; i >= 0; i--) { byte removed = remove(keysInRange[i]); put(keysInRange[i] + 1, removed); } // putting the new object in key. if (obj != null) { put(key, SparseByteColumn.toByte(obj)); } }
/** * Replaces the object with the specified key with the object passed in. * * @param obj Object that should replace the one at key * @param key Key of the object to replace */ public void replaceObject(Object obj, int key) { put(key, SparseByteColumn.toByte(obj)); }