Package org.eclipse.jgit.util
Class RefList.Builder<T extends Ref>
java.lang.Object
org.eclipse.jgit.util.RefList.Builder<T>
- Type Parameters:
T
- type of reference being stored.
Builder to facilitate fast construction of an immutable RefList.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the reference to the end of the array.void
Add all items from a source array.void
addAll
(RefList.Builder other) Add all items from another builder.(package private) void
dedupe
(BinaryOperator<T> mergeFunction) Dedupe the refs in place.get
(int idx) Get the reference at a particular index.void
remove
(int idx) Remove an item at a specific index.void
Replace a single existing element.int
size()
void
sort()
Sort the list's backing array in-place.toString()
-
Field Details
-
list
-
size
private int size
-
-
Constructor Details
-
Builder
public Builder()Create an empty list ready for items to be added. -
Builder
public Builder(int capacity) Create an empty list with at least the specified capacity.- Parameters:
capacity
- the new capacity; if zero or negative, behavior is the same asBuilder()
.
-
-
Method Details
-
size
public int size()- Returns:
- number of items in this builder's internal collection.
-
get
Get the reference at a particular index.- Parameters:
idx
- the index to obtain. Must be0 <= idx < size()
.- Returns:
- the reference value, never null.
-
remove
public void remove(int idx) Remove an item at a specific index.- Parameters:
idx
- position to remove the item from.
-
add
Add the reference to the end of the array.References must be added in sort order, or the array must be sorted after additions are complete using
sort()
.- Parameters:
ref
-
-
addAll
Add all items from another builder.- Parameters:
other
-- Since:
- 5.4
-
addAll
Add all items from a source array.References must be added in sort order, or the array must be sorted after additions are complete using
sort()
.- Parameters:
src
- the source array.off
- position withinsrc
to start copying from.cnt
- number of items to copy fromsrc
.
-
set
Replace a single existing element.- Parameters:
idx
- index, must have already been added previously.ref
- the new reference.
-
sort
public void sort()Sort the list's backing array in-place. -
dedupe
Dedupe the refs in place. Must be called aftersort()
.- Parameters:
mergeFunction
-
-
toRefList
- Returns:
- an unmodifiable list using this collection's backing array.
-
toString
-