/** * Expands the set to accomodate new values. * * @param newCapacity an <code>int</code> value */ protected void rehash(int newCapacity) { int oldCapacity = _set.length; Object oldSet[] = _set; _set = new Object[newCapacity]; for (int i = oldCapacity; i-- > 0;) { if(oldSet[i] != null && oldSet[i] != REMOVED) { Object o = oldSet[i]; int index = insertionIndex(o); _set[index] = o; } } }
/** * Inserts a value into the set. * * @param obj an <code>Object</code> value * @return true if the set was modified by the add operation */ public boolean add(Object obj) { int index = insertionIndex(obj); if (index < 0) { return false; // already present in set, nothing to add } Object old = _set[index]; _set[index] = obj; postInsertHook(old == null); return true; // yes, we added something }