/** * Returns a hash code for this set. * * This method overrides the generic method provided by the superclass. Since * {@code equals()} is not overriden, it is important that the value returned by * this method is the same value as the one returned by the overriden method. * * @return a hash code for this set. */ @Override public int hashCode() { int h = 0; for (int j = realSize(), i = 0; j-- != 0;) { while (((key[i]) == null)) i++; if (this != key[i]) h += (strategy.hashCode(key[i])); i++; } // Zero / null have hash zero. return h; } private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
/** * Rehashes the set. * * <p> * This method implements the basic rehashing strategy, and may be overriden by * subclasses implementing different rehashing strategies (e.g., disk-based * rehashing). However, you should not override this method unless you * understand the internal workings of this class. * * @param newN * the new size */ @SuppressWarnings("unchecked") protected void rehash(final int newN) { final K key[] = this.key; final int mask = newN - 1; // Note that this is used by the hashing macro final K newKey[] = (K[]) new Object[newN + 1]; int i = n, pos; for (int j = realSize(); j-- != 0;) { while (((key[--i]) == null)); if (!((newKey[pos = (it.unimi.dsi.fastutil.HashCommon.mix(strategy.hashCode(key[i]))) & mask]) == null)) while (!((newKey[pos = (pos + 1) & mask]) == null)); newKey[pos] = key[i]; } n = newN; this.mask = mask; maxFill = maxFill(n, f); this.key = newKey; } /**