@@ -0,0 +1,2333 @@
+/*%0A *  Copyright 2016-2017 Real Logic Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.agrona.collections;%0A%0Aimport java.util.ArrayList;%0A%0A/**%0A * Utility functions for working with %7B@link ArrayList%7Ds.%0A */%0Apublic class ArrayListUtil%0A%7B%0A    /**%0A     * Removes element at index, but instead of copying all elements to the left, moves into the same slot the last%0A     * element. This avoids the copy costs, but spoils the list order. If index is the last element it is just removed.%0A     *%0A     * @param list      to be modified.%0A     * @param index     to be removed.%0A     * @param lastIndex last element index in the list to be swapped into the removed index.%0A     * @param %3CT%3E       element type.%0A     * @throws IndexOutOfBoundsException if index or lastIndex are out of bounds.%0A     */%0A    public static %3CT%3E void fastUnorderedRemove(final ArrayList%3CT%3E list, final int index, final int lastIndex)%0A    %7B%0A        final T last = list.remove(lastIndex);%0A        if (index != lastIndex)%0A        %7B%0A            list.set(index, last);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Removes element but instead of copying all elements to the left, moves into the same slot the last element.%0A     * This avoids the copy costs, but spoils the list order. If element is the last element then it is just removed.%0A     *%0A     * @param list to be modified.%0A     * @param e    to be removed.%0A     * @param %3CT%3E  element type.%0A     * @return true if found and removed, false otherwise.%0A     */%0A    public static %3CT%3E boolean fastUnorderedRemove(final ArrayList%3CT%3E list, final T e)%0A    %7B%0A        for (int i = 0, size = list.size(); i %3C size; i++)%0A        %7B%0A            if (e == list.get(i))%0A            %7B%0A                fastUnorderedRemove(list, i, size - 1);%0A                return true;%0A            %7D%0A        %7D%0A%0A        return false;%0A    %7D%0A%7D%0A%0A

Add ArrayListUtil.