Package ubic.gemma.model.util
Class SparseListUtils
java.lang.Object
ubic.gemma.model.util.SparseListUtils
Utilities for dealing with sparse
List
- Author:
- poirigui
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
getSparseArrayElement
(List<T> array, int[] indices, int numberOfElements, int index, T defaultValue) Get an element of a sparse array.static <T> T
getSparseRangeArrayElement
(List<T> array, int[] offsets, int numberOfElements, int index) Get an element of a sparse range array.static <T> void
validateSparseArray
(List<T> array, int[] indices, int numberOfElements, T defaultValue) static void
validateSparseRangeArray
(List<?> array, int[] offsets, int numberOfElements) Validate a sparse range array.
-
Constructor Details
-
SparseListUtils
public SparseListUtils()
-
-
Method Details
-
getSparseArrayElement
public static <T> T getSparseArrayElement(List<T> array, int[] indices, int numberOfElements, int index, T defaultValue) Get an element of a sparse array. -
validateSparseArray
-
getSparseRangeArrayElement
public static <T> T getSparseRangeArrayElement(List<T> array, int[] offsets, int numberOfElements, int index) throws IllegalArgumentException, IndexOutOfBoundsException Get an element of a sparse range array.- Parameters:
array
- collection of elements applying for the rangesoffsets
- starting offsets of the rangesnumberOfElements
- the size of the original arrayindex
- a position to retrieve- Throws:
IndexOutOfBoundsException
- if the requested index is out of boundsIllegalArgumentException
- if the array is empty or its size differs from offsets- See Also:
-
validateSparseRangeArray
public static void validateSparseRangeArray(List<?> array, int[] offsets, int numberOfElements) throws IllegalArgumentException Validate a sparse range array.- Parameters:
array
- collection of elements applying for the rangesoffsets
- starting offsets of the rangesnumberOfElements
- the size of the original array- Throws:
IllegalArgumentException
- if the sparse range array is invalid
-