Top Description Inners Fields Constructors Methods
org.eclipse.jgit.util

public Class IntList

extends Object
Class Inheritance

A more efficient List<Integer> using a primitive integer array.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
IntList.IntComparator

A comparator of primitive ints.

Field Summary

Modifier and TypeField and Description
private int
private int[]

Constructor Summary

AccessConstructor and Description
public
IntList()

Create an empty list with a default capacity.

public
IntList(int
number of entries the list can initially hold.
capacity
)

Create an empty list with the specified capacity.

Method Summary

Modifier and TypeMethod and Description
public void
add(int
the number to add.
n
)

Add an entry to the end of the list.

public void
clear()

Empty this list

public boolean

Returns:

true of value appears in this list.
contains
(int
the value to search for.
value
)

Check if an entry appears in this collection.

public static IntList

Returns:

the list initialized with the given range
filledWithRange
(int
the beginning of the range, inclusive
start
,
int
the end of the range, exclusive
end
)

Create a list initialized with the values of the given range.

public void
fillTo(int
index position to stop filling at. 0 inserts no filler. 1 ensures the list has a size of 1, adding val if the list is currently empty.
toIndex
,
int
value to insert into padded positions.
val
)

Pad the list with entries.

public int

Returns:

the number at the specified index
get
(int
index to read, must be in the range [0, size()).
i
)

Get the value at the specified index

private void
grow()

private int
partition(int begin, int end, IntList.IntComparator comparator)

private void
quickSort(int
the index to begin partitioning at, inclusive
begin
,
int
the index to end partitioning at, inclusive
end
,
IntList.IntComparator
provides the comparison values for sorting the entries
comparator
)

Quick sort has average time complexity of O(n log n) and O(log n) space complexity (for recursion on the stack).

public void
set(int
index to set, must be in the range [0, size()).
index
,
int
value to store at the position.
n
)

Assign an entry in the list.

public int

Returns:

number of entries in this list.
size
()

Get number of entries in this list.

public void
sort(IntList.IntComparator
provides the comparison values for sorting the entries
comparator
)

Sort the entries of the list in-place, according to the comparator.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

countback to summary
private int count
entriesback to summary
private int[] entries

Constructor Detail

IntListback to summary
public IntList()

Create an empty list with a default capacity.

IntListback to summary
public IntList(int capacity)

Create an empty list with the specified capacity.

Parameters
capacity:int

number of entries the list can initially hold.

Method Detail

addback to summary
public void add(int n)

Add an entry to the end of the list.

Parameters
n:int

the number to add.

clearback to summary
public void clear()

Empty this list

containsback to summary
public boolean contains(int value)

Check if an entry appears in this collection.

Parameters
value:int

the value to search for.

Returns:boolean

true of value appears in this list.

Since
4.9
filledWithRangeback to summary
public static IntList filledWithRange(int start, int end)

Create a list initialized with the values of the given range.

Parameters
start:int

the beginning of the range, inclusive

end:int

the end of the range, exclusive

Returns:IntList

the list initialized with the given range

Since
6.6
fillToback to summary
public void fillTo(int toIndex, int val)

Pad the list with entries.

Parameters
toIndex:int

index position to stop filling at. 0 inserts no filler. 1 ensures the list has a size of 1, adding val if the list is currently empty.

val:int

value to insert into padded positions.

getback to summary
public int get(int i)

Get the value at the specified index

Parameters
i:int

index to read, must be in the range [0, size()).

Returns:int

the number at the specified index

Exceptions
ArrayIndexOutOfBoundsException:
the index outside the valid range
growback to summary
private void grow()
partitionback to summary
private int partition(int begin, int end, IntList.IntComparator comparator)
quickSortback to summary
private void quickSort(int begin, int end, IntList.IntComparator comparator)

Quick sort has average time complexity of O(n log n) and O(log n) space complexity (for recursion on the stack).

Implementation based on https://www.baeldung.com/java-quicksort.

Parameters
begin:int

the index to begin partitioning at, inclusive

end:int

the index to end partitioning at, inclusive

comparator:IntList.IntComparator

provides the comparison values for sorting the entries

setback to summary
public void set(int index, int n)

Assign an entry in the list.

Parameters
index:int

index to set, must be in the range [0, size()).

n:int

value to store at the position.

sizeback to summary
public int size()

Get number of entries in this list.

Returns:int

number of entries in this list.

sortback to summary
public void sort(IntList.IntComparator comparator)

Sort the entries of the list in-place, according to the comparator.

Parameters
comparator:IntList.IntComparator

provides the comparison values for sorting the entries

Since
6.6
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jgit.util back to summary

public Interface IntList.IntComparator

Known Direct Implementers
org.eclipse.jgit.internal.storage.file.PackReverseIndexWriterV1.IndexPositionsByOffsetComparator

A comparator of primitive ints.
Since
6.6

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

a negative number if first < second, 0 if first == second, or a positive number if first > second
compare
(int
the first int to compare
first
,
int
the second int to compare
second
)

Compares the two int arguments for order.

Method Detail

compareback to summary
public int compare(int first, int second)

Compares the two int arguments for order.

Parameters
first:int

the first int to compare

second:int

the second int to compare

Returns:int

a negative number if first < second, 0 if first == second, or a positive number if first > second