java.lang.Object
org.jhotdraw8.collection.util.ListHelper
Provides static methods for lists that are based on arrays.
- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptioncopyAddAll(@NonNull T @NonNull [] src, int index, @NonNull T @NonNull [] values) Copies 'src' and inserts 'values' at position 'index'.copyComponentAdd(@NonNull T @NonNull [] src, int index, int numComponents) Copies 'src' and inserts 'numComponents' at position 'index'.copyComponentRemove(@NonNull T @NonNull [] src, int index, int numComponents) Copies 'src' and removes 'numComponents' at position 'index'.Copies 'src' and sets 'value' at position 'index'.static byte @NonNull []Grows an items array.static char @NonNull []Grows an items array.static double @NonNull []Grows an items array.static int @NonNull []Grows an items array.static long @NonNull []Grows an items array.static short @NonNull []Grows an items array.Grows an items array.static byte @NonNull []trimToSize(int size, int itemSize, byte @NonNull [] items) Resizes an array to fit the number of items.static double @NonNull []trimToSize(int size, int itemSize, double @NonNull [] items) Resizes an array to fit the number of items.static int @NonNull []trimToSize(int size, int itemSize, int @NonNull [] items) Resizes an array to fit the number of items.static long @NonNull []trimToSize(int size, int itemSize, long @NonNull [] items) Resizes an array to fit the number of items.trimToSize(int size, int itemSize, @NonNull Object @NonNull [] items) Resizes an array to fit the number of items.
-
Method Details
-
copyAddAll
public static <T> @NonNull T @NonNull [] copyAddAll(@NonNull T @NonNull [] src, int index, @NonNull T @NonNull [] values) Copies 'src' and inserts 'values' at position 'index'.- Type Parameters:
T- the array type- Parameters:
src- an arrayindex- an indexvalues- the values- Returns:
- a new array
-
copyComponentAdd
public static <T> @NonNull T @NonNull [] copyComponentAdd(@NonNull T @NonNull [] src, int index, int numComponents) Copies 'src' and inserts 'numComponents' at position 'index'.The new components will have a null value.
- Type Parameters:
T- the array type- Parameters:
src- an arrayindex- an indexnumComponents- the number of array components to be added- Returns:
- a new array
-
copyComponentRemove
public static <T> @NonNull T @NonNull [] copyComponentRemove(@NonNull T @NonNull [] src, int index, int numComponents) Copies 'src' and removes 'numComponents' at position 'index'.- Type Parameters:
T- the array type- Parameters:
src- an arrayindex- an indexnumComponents- the number of array components to be removed- Returns:
- a new array
-
copySet
Copies 'src' and sets 'value' at position 'index'.- Type Parameters:
T- the array type- Parameters:
src- an arrayindex- an indexvalue- a value- Returns:
- a new array
-
grow
public static @NonNull Object @NonNull [] grow(int targetCapacity, int itemSize, @NonNull Object @NonNull [] items) Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
grow
Grows an items array.- Parameters:
targetCapacity- >= 0itemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of larger size or the same if no resizing is necessary
-
trimToSize
public static @NonNull Object @NonNull [] trimToSize(int size, int itemSize, @NonNull Object @NonNull [] items) Resizes an array to fit the number of items.- Parameters:
size- the size to fititemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of smaller size or the same if no resizing is necessary
-
trimToSize
Resizes an array to fit the number of items.- Parameters:
size- the size to fititemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of smaller size or the same if no resizing is necessary
-
trimToSize
Resizes an array to fit the number of items.- Parameters:
size- the size to fititemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of smaller size or the same if no resizing is necessary
-
trimToSize
Resizes an array to fit the number of items.- Parameters:
size- the size to fititemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of smaller size or the same if no resizing is necessary
-
trimToSize
Resizes an array to fit the number of items.- Parameters:
size- the size to fititemSize- number of array elements that an item occupiesitems- the items array- Returns:
- a new item array of smaller size or the same if no resizing is necessary
-