Class SortIndex<T>
- java.lang.Object
-
- org.jacoco.report.internal.html.table.SortIndex<T>
-
- Type Parameters:
T
- type of the items
final class SortIndex<T> extends java.lang.Object
A index on a list of items sorted with a givenComparator
. The index does not change the list itself.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SortIndex.Entry
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>
comparator
private java.util.List<SortIndex.Entry>
list
private int[]
positions
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getPosition(int idx)
Returns the sorted position of the element with the given index in the items list provided to the init() method.void
init(java.util.List<? extends T> items)
Initializes the index for the given list of items.
-
-
-
Field Detail
-
comparator
private final java.util.Comparator<? super T> comparator
-
list
private final java.util.List<SortIndex.Entry> list
-
positions
private int[] positions
-
-
Constructor Detail
-
SortIndex
public SortIndex(java.util.Comparator<? super T> comparator)
Creates a new index based in the given comparator.- Parameters:
comparator
- comparator to sort items
-
-
Method Detail
-
init
public void init(java.util.List<? extends T> items)
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
-
-