/** * 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]) == ((short) 0))) i++; h += (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 */ protected void rehash(final int newN) { final short key[] = this.key; final int mask = newN - 1; // Note that this is used by the hashing macro final short newKey[] = new short[newN + 1]; int i = n, pos; for (int j = realSize(); j-- != 0;) { while (((key[--i]) == ((short) 0))); if (!((newKey[pos = (it.unimi.dsi.fastutil.HashCommon.mix((key[i]))) & mask]) == ((short) 0))) while (!((newKey[pos = (pos + 1) & mask]) == ((short) 0))); newKey[pos] = key[i]; } n = newN; this.mask = mask; maxFill = maxFill(n, f); this.key = newKey; } /**