ArrayBasedLongToInternalIntFixedLengthBiMap implements LongToInternalIntBiMap { @Override public int put(long key) { long primaryHashValue = primaryHashFunction(key); int bucket = (int) (primaryHashValue & bitMask); long currentKey = array.get(bucket); if (currentKey == defaultGetReturnValue) { if (isAtCapacity()) { throw new RuntimeException("Exceeded the maximum number of insertions"); } array.set(bucket, key); size.getAndIncrement(); numStoredKeysCounter.incr(); return bucket; } else if (currentKey == key) { return bucket; } int secondaryHashKey = secondaryHashFunction(key, bitMask); do { bucket = (int) (((long) bucket + secondaryHashKey) & bitMask); currentKey = array.get(bucket); } while ((currentKey != defaultGetReturnValue) && (currentKey != key)); if (currentKey == defaultGetReturnValue) { if (isAtCapacity()) { throw new RuntimeException("Exceeded the maximum number of insertions"); } array.set(bucket, key); size.getAndIncrement(); numStoredKeysCounter.incr(); return bucket; } else { return bucket; } } ArrayBasedLongToInternalIntFixedLengthBiMap(
      int capacity,
      double loadFactor,
      int defaultGetReturnValue,
      long defaultGetKeyReturnValue,
      StatsReceiver statsReceiver); @Override int get(long key); @Override int put(long key); @Override long getKey(int value); @Override void clear();  }
@Test public void testPutThrowsRuntimeException() { NullStatsReceiver nullStatsReceiver = new NullStatsReceiver(); ArrayBasedLongToInternalIntFixedLengthBiMap arrayBasedLongToInternalIntFixedLengthBiMap = new ArrayBasedLongToInternalIntFixedLengthBiMap(204, 0.0, 204, 204, nullStatsReceiver); try { arrayBasedLongToInternalIntFixedLengthBiMap.put(0L); fail("Expecting exception: RuntimeException"); } catch (RuntimeException e) { assertEquals(ArrayBasedLongToInternalIntFixedLengthBiMap.class.getName(), e.getStackTrace()[0].getClassName()); } }