protected abstract static class IList.IReadOnlyList<E> extends IList<E>
IList.IReadOnlyList<E>, IList.IReadOnlyListFromArray<E>, IList.IReadOnlyListFromCollection<E>, IList.IReadOnlyListFromList<E>, IList.IReadOnlyListFromMult<E>| Modifier | Constructor and Description |
|---|---|
protected |
IReadOnlyList() |
| Modifier and Type | Method and Description |
|---|---|
<K> int |
binarySearch(int index,
int len,
K key,
java.util.Comparator<? super K> comparator)
Searches the specified range for an object using the binary search algorithm.
|
int |
capacity()
Returns capacity of this list.
|
protected boolean |
doAdd(int index,
E elem)
Helper method for adding an element to the list.
|
protected void |
doAssign(IList<E> that)
Assign this list the content of the that list.
|
protected void |
doClone(IList<E> that)
Initialize this object after the bitwise copy has been made by Object.clone().
|
protected IList<E> |
doCreate(int capacity)
Create list with specified capacity.
|
protected void |
doEnsureCapacity(int minCapacity)
Increases the capacity of this list instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
protected E |
doRemove(int index)
Helper method to remove an element.
|
protected E |
doReSet(int index,
E elem)
Sets an element at specified position.
|
protected E |
doSet(int index,
E elem)
Helper method for setting an element in the list.
|
protected E |
getDefaultElem() |
void |
sort(int index,
int len,
java.util.Comparator<? super E> comparator)
Sort specified elements in the list using the specified comparator.
|
void |
trimToSize()
An application can use this operation to minimize the storage of an instance.
|
IList<E> |
unmodifiableList()
Returns an unmodifiable view of this list.
|
add, add, addAll, addAll, addAll, addAll, addArray, addArray, addArray, addArray, addFirst, addIfAbsent, addLast, addMult, addMult, binarySearch, checkIndex, checkIndexAdd, checkLength, checkLengths, checkNonNull, checkRange, clear, clone, contains, containsAll, containsAny, containsIf, copy, copy, descendingIterator, doAddAll, doClear, doCreateArray, doGet, doGetAll, doModify, doRemoveAll, doReplaceAll, doRotate, drag, element, ensureCapacity, equals, extract, extractIf, fill, filter, filteredList, get, getAll, getAll, getCount, getDistinct, getFirst, getIf, getLast, getSingle, getSingleOrEmpty, hashCode, indexOf, indexOf, indexOfIf, initAll, initAll, initArray, initMult, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, mappedList, move, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, put, putAll, putAll, putArray, putMult, remove, remove, remove, remove, removeAll, removeAll, removeAll, removeFirst, removeFirstOccurrence, removeIf, removeLast, removeLastOccurrence, replaceAll, replaceAll, replaceArray, replaceMult, resize, retainAll, retainAll, retainIf, reverse, reverse, rotate, rotate, set, setAll, setAll, setArray, setArray, setMult, size, sort, swap, toArray, toArray, toArray, toArray, toArray, toArray, toString, transferCopy, transferMove, transferRemove, transferSwap, transform, transformedListpublic IList<E> unmodifiableList()
IListunmodifiableList in class IList<E>protected void doClone(IList<E> that)
IListpublic int capacity()
IListprotected E doSet(int index, E elem)
IListprotected E doReSet(int index, E elem)
IListprotected E getDefaultElem()
getDefaultElem in class IList<E>protected boolean doAdd(int index,
E elem)
IListprotected E doRemove(int index)
IListprotected void doEnsureCapacity(int minCapacity)
IListdoEnsureCapacity in class IList<E>minCapacity - the desired minimum capacitypublic void trimToSize()
IListtrimToSize in class IList<E>protected IList<E> doCreate(int capacity)
IListprotected void doAssign(IList<E> that)
IListpublic void sort(int index,
int len,
java.util.Comparator<? super E> comparator)
IListpublic <K> int binarySearch(int index,
int len,
K key,
java.util.Comparator<? super K> comparator)
IListNote that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:
persons.binarySearch("john", new SearchByName());
class SearchByName implements Comparator<Object> {
public int compare(Object o1, Object o2) {
String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
return s1.compareTo(s2);
}
}
/binarySearch in class IList<E>index - index of first element to searchlen - number of elements to searchkey - the value to be searched forcomparator - the comparator by which the list is ordered.
A null value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)