IntToIntMap (@NotNull final Flags visibleIndexes, int shortSize, int blockSize) { if (shortSize < 0) throw new NegativeArraySizeException("shortSize < 0: " + shortSize); if (shortSize == 0) return createEmptyIntToIntMap(visibleIndexes); int[] strongShortIndexes = new int[(shortSize - 1) / blockSize + 1]; int currentShortIndex = -1; for (int longIndex = 0; longIndex < visibleIndexes.size(); longIndex++) { if (visibleIndexes.get(longIndex)) { currentShortIndex++; if (currentShortIndex % blockSize == 0) strongShortIndexes[currentShortIndex / blockSize] = longIndex; } } return new PermanentListIntToIntMap(visibleIndexes, shortSize, blockSize, strongShortIndexes); }