/** * 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(E obj) { int index = insertKey(obj); if (index < 0) { return false; // already present in set, nothing to add } postInsertHook(consumeFreeSlot); return true; // yes, we added something }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }
/** * 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(E obj) { int index = insertKey(obj); if (index < 0) { return false; // already present in set, nothing to add } postInsertHook(consumeFreeSlot); return true; // yes, we added something }
/** * 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(E obj) { int index = insertKey(obj); if (index < 0) { return false; // already present in set, nothing to add } postInsertHook(consumeFreeSlot); return true; // yes, we added something }
/** * Inserts a value into the set. * * @param obj an <code>Object</code> value * @return true if the set was modified by the add operation */ @Override public boolean add(E obj) { int index = insertKey(obj); if (index < 0) { return false; // already present in set, nothing to add } postInsertHook(consumeFreeSlot); return true; // yes, we added something }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @Override @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }