@Test public void insertItems_beforePlacing() { checkInsertionPositions(7, adsAt15repeating, 1, 4, 6); adsAt15repeating.insertItem(4); adsAt15repeating.insertItem(7); checkInsertionPositions(9, adsAt15repeating, 1, 5, 8); }
void insertItem(final int originalPosition) { int indexToIncrement = binarySearchFirstEquals( mDesiredOriginalPositions, mDesiredCount, originalPosition); for (int i = indexToIncrement; i < mDesiredCount; ++i) { mDesiredOriginalPositions[i]++; mDesiredInsertionPositions[i]++; } indexToIncrement = binarySearchFirstEquals( mOriginalAdPositions, mPlacedCount, originalPosition); for (int i = indexToIncrement; i < mPlacedCount; ++i) { mOriginalAdPositions[i]++; mAdjustedAdPositions[i]++; } }
PlacementData { void insertItem(final int originalPosition) { int indexToIncrement = binarySearchFirstEquals( mDesiredOriginalPositions, mDesiredCount, originalPosition); for (int i = indexToIncrement; i < mDesiredCount; ++i) { mDesiredOriginalPositions[i]++; mDesiredInsertionPositions[i]++; } indexToIncrement = binarySearchFirstEquals( mOriginalAdPositions, mPlacedCount, originalPosition); for (int i = indexToIncrement; i < mPlacedCount; ++i) { mOriginalAdPositions[i]++; mAdjustedAdPositions[i]++; } } }
PlacementData { void insertItem(final int originalPosition) { int indexToIncrement = binarySearchFirstEquals( mDesiredOriginalPositions, mDesiredCount, originalPosition); for (int i = indexToIncrement; i < mDesiredCount; ++i) { mDesiredOriginalPositions[i]++; mDesiredInsertionPositions[i]++; } indexToIncrement = binarySearchFirstEquals( mOriginalAdPositions, mPlacedCount, originalPosition); for (int i = indexToIncrement; i < mPlacedCount; ++i) { mOriginalAdPositions[i]++; mAdjustedAdPositions[i]++; } } private  PlacementData(@NonNull final int[] desiredInsertionPositions); }
PlacementData { void insertItem(final int originalPosition) { int indexToIncrement = binarySearchFirstEquals( mDesiredOriginalPositions, mDesiredCount, originalPosition); for (int i = indexToIncrement; i < mDesiredCount; ++i) { mDesiredOriginalPositions[i]++; mDesiredInsertionPositions[i]++; } indexToIncrement = binarySearchFirstEquals( mOriginalAdPositions, mPlacedCount, originalPosition); for (int i = indexToIncrement; i < mPlacedCount; ++i) { mOriginalAdPositions[i]++; mAdjustedAdPositions[i]++; } } private  PlacementData(@NonNull final int[] desiredInsertionPositions);  }
PlacementData { void insertItem(final int originalPosition) { int indexToIncrement = binarySearchFirstEquals( mDesiredOriginalPositions, mDesiredCount, originalPosition); for (int i = indexToIncrement; i < mDesiredCount; ++i) { mDesiredOriginalPositions[i]++; mDesiredInsertionPositions[i]++; } indexToIncrement = binarySearchFirstEquals( mOriginalAdPositions, mPlacedCount, originalPosition); for (int i = indexToIncrement; i < mPlacedCount; ++i) { mOriginalAdPositions[i]++; mAdjustedAdPositions[i]++; } } private  PlacementData(@NonNull final int[] desiredInsertionPositions);  final static int NOT_FOUND; }