RefDatabase.
This list is a hybrid of a Map<String,Ref> and of a List<Ref>. It tracks reference instances by name by keeping them sorted and performing binary search to locate an entry. Lookup time is O(log N), but addition and removal is O(N + log N) due to the list expansion or contraction costs.
This list type is copy-on-write. Mutation methods return a new copy of the
list, leaving this unmodified. As a result we cannot easily implement
the java. interface contract.
| Modifier and Type | Class and Description |
|---|---|
| public static class | RefList.
type of reference being stored. T extends Ref>Builder to facilitate fast construction of an immutable RefList. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final int | |
| private static final RefList | |
| pack-priv final Ref[] |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public final RefList | Returns: copy of this list, after making space for and addingref.position to add the item at. If negative the method assumes it
was a direct return value from idx, T find(String) and will
adjust it to the correct position.the new reference to insert. ref)Add an item at a specific index. |
| public final List | |
| public final boolean | |
| public final RefList. | Returns: a new builder with the firstn elements already added.the number of elements to copy. n)Obtain a builder initialized with the first |
| public static < type of reference being stored. T extends Ref> RefList | Returns: an empty unmodifiable reference list.Create an empty unmodifiable reference list. |
| public final int | |
| public final T | |
| public final T | Returns: the reference value, never null.the index to obtain. Must be idx)0 <= idx < size().Get the reference at a particular index. |
| public final boolean | |
| public Iterator | |
| public final RefList | Returns: copy of this list, after performing the addition or replacement.the reference to store. ref)Store a reference, adding or replacing as necessary. |
| public final RefList | Returns: copy of this list, after making removing the item atidx.position to remove the item from. idx)Remove an item at a specific index. |
| public final RefList | Returns: copy of this list, after replacingidx with ref .index of the element to change. idx, T the new value, must not be null. ref)Obtain a new copy of the list after changing one element. |
| public final int | |
| public static < type of reference being stored. T extends Ref> Collector | |
| public String |
| cnt | back to summary |
|---|---|
| pack-priv final int cnt | |
| EMPTY | back to summary |
|---|---|
| private static final RefList<Ref> EMPTY | |
| list | back to summary |
|---|---|
| pack-priv final Ref[] list | |
| RefList | back to summary |
|---|---|
| pack-priv RefList(Ref[] list, int cnt) | |
| RefList | back to summary |
|---|---|
| protected RefList(RefList<T> src) Initialize this list to use the same backing array as another list.
| |
| add | back to summary |
|---|---|
| public final RefList Add an item at a specific index. This list instance is not affected by the addition. Because this method copies the entire list, it runs in O(N) time.
| |
| asList | back to summary |
|---|---|
| public final List Cast
| |
| contains | back to summary |
|---|---|
| public final boolean contains(String name) Determine if a reference is present.
| |
| copy | back to summary |
|---|---|
| public final RefList. Obtain a builder initialized with the first
Copies the first | |
| emptyList | back to summary |
|---|---|
| public static <T extends Ref> RefList Create an empty unmodifiable reference list.
| |
| find | back to summary |
|---|---|
| public final int find(String name) Locate an entry by name.
| |
| get | back to summary |
|---|---|
| public final T get(String name) Get a reference object by name.
| |
| get | back to summary |
|---|---|
| public final T get(int idx) Get the reference at a particular index.
| |
| isEmpty | back to summary |
|---|---|
| public final boolean isEmpty() Get if this list is empty.
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| put | back to summary |
|---|---|
| public final RefList Store a reference, adding or replacing as necessary. This list instance is not affected by the store. The correct position is determined, and the item is added if missing, or replaced if existing. Because this method copies the entire list, it runs in O(N + log N) time.
| |
| remove | back to summary |
|---|---|
| public final RefList Remove an item at a specific index. This list instance is not affected by the addition. Because this method copies the entire list, it runs in O(N) time.
| |
| set | back to summary |
|---|---|
| public final RefList Obtain a new copy of the list after changing one element. This list instance is not affected by the replacement. Because this method copies the entire list, it runs in O(N) time.
| |
| size | back to summary |
|---|---|
| public final int size() Get number of items in this list.
| |
| toRefList | back to summary |
|---|---|
public static <T extends Ref> Collector
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| pack-priv void | |
| public T | Returns: the reference value, never null.the index to obtain. Must be idx)0 <= idx < size().Get the reference at a particular index. |
| public void | |
| public void | set(int
index, must have already been added previously. idx, T the new reference. ref)Replace a single existing element. |
| public int | |
| public void | |
| public RefList | Returns: an unmodifiable list using this collection's backing array.Get unmodifiable list based on this list |
| public String |
| Builder | back to summary |
|---|---|
| public Builder() Create an empty list ready for items to be added. | |
| Builder | back to summary |
|---|---|
| public Builder(int capacity) Create an empty list with at least the specified capacity.
| |
| add | back to summary |
|---|---|
| public void add(T ref) 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
| |
| addAll | back to summary |
|---|---|
| public void addAll(RefList. Add all items from another builder. | |
| addAll | back to summary |
|---|---|
| public void addAll(Ref[] src, int off, int cnt) 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
| |
| dedupe | back to summary |
|---|---|
| pack-priv void dedupe(BinaryOperator<T> mergeFunction) Dedupe the refs in place. Must be called after
| |
| get | back to summary |
|---|---|
| public T get(int idx) Get the reference at a particular index.
| |
| remove | back to summary |
|---|---|
| public void remove(int idx) Remove an item at a specific index.
| |
| set | back to summary |
|---|---|
| public void set(int idx, T ref) Replace a single existing element.
| |
| size | back to summary |
|---|---|
| public int size() Get size
| |
| sort | back to summary |
|---|---|
| public void sort() Sort the list's backing array in-place. | |
| toRefList | back to summary |
|---|---|
| public RefList Get unmodifiable list based on this list
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |