Class SortIndex<T>
java.lang.Object
org.jacoco.report.internal.html.table.SortIndex<T>
- Type Parameters:
T
- type of the items
A index on a list of items sorted with a given
Comparator
. The index
does not change the list itself.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSortIndex
(Comparator<? super T> comparator) Creates a new index based in the given comparator. -
Method Summary
Modifier and TypeMethodDescriptionint
getPosition
(int idx) Returns the sorted position of the element with the given index in the items list provided to the init() method.void
Initializes the index for the given list of items.
-
Field Details
-
comparator
-
list
-
positions
private int[] positions
-
-
Constructor Details
-
SortIndex
Creates a new index based in the given comparator.- Parameters:
comparator
- comparator to sort items
-
-
Method Details
-
init
Initializes the index for the given list of items.- Parameters:
items
- list of items
-
getPosition
public int getPosition(int idx) Returns the sorted position of the element with the given index in the items list provided to the init() method.- Parameters:
idx
- index of a element of the list- Returns:
- its position in a sorted list
-