public void removeElementsInRange(int inBeginIndex, int inEndIndex, ElementProcessingDelegate inProcessingDelegate) { validateIndex(inBeginIndex); validateIndex(inEndIndex); XUtils.check(inBeginIndex <= inEndIndex); int theLastIndex = getLastIndex(); int theElementsNumToRemove = inEndIndex - inBeginIndex; int theRemovingElementsOffset = theElementsNumToRemove + 1; if (null != inProcessingDelegate) { for (int theIndex = inBeginIndex; theIndex < inEndIndex; ++theIndex) { inProcessingDelegate.Invoke(_elements[theIndex]); } } if (inEndIndex != theLastIndex) { int theLastMovingElementIndex = theLastIndex - theRemovingElementsOffset; for (int theIndex = inBeginIndex; theIndex <= theLastMovingElementIndex; ++theIndex) { _elements[theIndex] = _elements[theIndex + theRemovingElementsOffset]; } } _size -= theElementsNumToRemove; }
public void removeElementsUpToEnd(int inBeginIndex, ElementProcessingDelegate inProcessingDelegate) { removeElementsInRange(inBeginIndex, getSize() - 1, inProcessingDelegate); }