Package org.agrona.collections
Class ArrayListUtil
java.lang.Object
org.agrona.collections.ArrayListUtil
Utility functions for working with
ArrayList
s.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
fastUnorderedRemove
(ArrayList<T> list, int index) Removes element at index, but instead of copying all elements to the left, moves into the same slot the last element.static <T> void
fastUnorderedRemove
(ArrayList<T> list, int index, int lastIndex) Removes element at index, but instead of copying all elements to the left, moves into the same slot the last element.static <T> boolean
fastUnorderedRemove
(ArrayList<T> list, T e) Removes element but instead of copying all elements to the left, moves into the same slot the last element.
-
Constructor Details
-
ArrayListUtil
private ArrayListUtil()
-
-
Method Details
-
fastUnorderedRemove
Removes element at index, but instead of copying all elements to the left, moves into the same slot the last element. This avoids the copy costs, but spoils the list order. If index is the last element it is just removed.- Type Parameters:
T
- element type.- Parameters:
list
- to be modified.index
- to be removed.- Throws:
IndexOutOfBoundsException
- if index is out of bounds.
-
fastUnorderedRemove
Removes element at index, but instead of copying all elements to the left, moves into the same slot the last element. This avoids the copy costs, but spoils the list order. If index is the last element it is just removed.- Type Parameters:
T
- element type.- Parameters:
list
- to be modified.index
- to be removed.lastIndex
- last element index in the list to be swapped into the removed index.- Throws:
IndexOutOfBoundsException
- if index or lastIndex are out of bounds.
-
fastUnorderedRemove
Removes element but instead of copying all elements to the left, moves into the same slot the last element. This avoids the copy costs, but spoils the list order. If element is the last element then it is just removed.- Type Parameters:
T
- element type.- Parameters:
list
- to be modified.e
- to be removed.- Returns:
- true if found and removed, false otherwise.
-