java.lang.Object
org.eclipse.jgit.util.IntList
A more efficient List<Integer> using a primitive integer array.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA comparator of primitive ints. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int n) Add an entry to the end of the list.voidclear()Empty this listbooleancontains(int value) Check if an entry appears in this collection.static IntListfilledWithRange(int start, int end) Create a list initialized with the values of the given range.voidfillTo(int toIndex, int val) Pad the list with entries.intget(int i) Get the value at the specified indexvoidset(int index, int n) Assign an entry in the list.intsize()Get number of entries in this list.voidsort(IntList.IntComparator comparator) Sort the entries of the list in-place, according to the comparator.toString()
-
Constructor Details
-
IntList
public IntList()Create an empty list with a default capacity. -
IntList
public IntList(int capacity) Create an empty list with the specified capacity.- Parameters:
capacity- number of entries the list can initially hold.
-
-
Method Details
-
filledWithRange
Create a list initialized with the values of the given range.- Parameters:
start- the beginning of the range, inclusiveend- the end of the range, exclusive- Returns:
- the list initialized with the given range
- Since:
- 6.6
-
size
public int size()Get number of entries in this list.- Returns:
- number of entries in this list.
-
contains
public boolean contains(int value) Check if an entry appears in this collection.- Parameters:
value- the value to search for.- Returns:
- true of
valueappears in this list. - Since:
- 4.9
-
get
public int get(int i) Get the value at the specified index- Parameters:
i- index to read, must be in the range [0,size()).- Returns:
- the number at the specified index
- Throws:
ArrayIndexOutOfBoundsException- the index outside the valid range
-
clear
public void clear()Empty this list -
add
public void add(int n) Add an entry to the end of the list.- Parameters:
n- the number to add.
-
set
public void set(int index, int n) Assign an entry in the list.- Parameters:
index- index to set, must be in the range [0,size()).n- value to store at the position.
-
fillTo
public void fillTo(int toIndex, int val) Pad the list with entries.- Parameters:
toIndex- index position to stop filling at. 0 inserts no filler. 1 ensures the list has a size of 1, addingvalif the list is currently empty.val- value to insert into padded positions.
-
sort
Sort the entries of the list in-place, according to the comparator.- Parameters:
comparator- provides the comparison values for sorting the entries- Since:
- 6.6
-
toString
-