KeyFMap (@NotNull Key<?> key) { int i = indexOf(key.hashCode()); if (i >= 0) { if (size() == 3) { int otherI1 = (2 - i) / 2; int otherI2 = 3 - (i + 2) / 2; Key<Object> key1 = Key.getKeyByIndex(keys[otherI1]); Key<Object> key2 = Key.getKeyByIndex(keys[otherI2]); if (key1 == null && key2 == null) return EMPTY_MAP; if (key1 == null) return new OneElementFMap<>(key2, values[otherI2]); if (key2 == null) return new OneElementFMap<>(key1, values[otherI1]); return new PairElementsFMap<>(key1, values[otherI1], key2, values[otherI2]); } int[] newKeys = ArrayUtil.remove(keys, i); Object[] newValues = ArrayUtil.remove(values, i, ArrayUtil.OBJECT_ARRAY_FACTORY); return new ArrayBackedFMap(newKeys, newValues); } return this; }