public interface IntList extends IntSizedIterable
Modifier and Type | Interface and Description |
---|---|
static class |
IntList.Single |
Modifier and Type | Method and Description |
---|---|
int |
binarySearch(int value)
Performs binary search.
|
int |
binarySearch(int value,
int from,
int to)
Performs binary search on list slice.
|
boolean |
contains(int value)
Checks whether collection contains specified value
|
int |
get(int index) |
IntList |
get(IntList indices)
Creates and returns a list which is this list indexed by
indices Analogy: get(index) returns one value from this list, get(indices) returns a list with multiple values from this list. |
int |
getNextDifferentValueIndex(int curIndex)
For a given index i, returns minimum index j, for which exactly one of the following holds:
j = -1 and for all k > i, a[k] = a[i] ;
j > i and a[i] != a[j] ,
where a represents the list. |
int |
indexOf(int value) |
boolean |
isEmpty()
Checks whether collection is empty.
|
boolean |
isSorted() |
boolean |
isSortedUnique() |
IntListIterator |
iterator() |
IntListIterator |
iterator(int from) |
IntListIterator |
iterator(int from,
int to) |
int |
size()
Size of the collection.
|
IntList |
subList(int from,
int to)
Returns a sub-list, backed by this list.
|
java.util.List<java.lang.Integer> |
toList() |
int[] |
toNativeArray()
Creates new native array and stores values there.
|
int[] |
toNativeArray(int startIndex,
int[] dest,
int destOffset,
int length)
Writes values to dest.
|
static final IntList EMPTY
int size()
size
in interface IntSizedIterable
boolean isEmpty()
boolean contains(int value)
value
- value to checkint get(int index) throws java.util.NoSuchElementException
java.util.NoSuchElementException
IntList get(IntList indices)
indices
[get(indices.get(0)), get(indices.get(1)), .., get(indices.get(indices.size() - 1))]
IntIndexedIterator
and IntListIndexedIterator
can be used
to iterate over this list via a custom set of indices.indices
in this listIntIndexedIterator
,
IntListIndexedIterator
int indexOf(int value)
int[] toNativeArray()
Note: effectively written code should avoid use this method.
int[] toNativeArray(int startIndex, int[] dest, int destOffset, int length)
IntList subList(int from, int to)
NB: If values are removed from the parent list, this may result in OOBE when accessing sublist.
from
- starting index, inclusiveto
- ending index, exclusiveint binarySearch(int value)
int binarySearch(int value, int from, int to)
boolean isSorted()
boolean isSortedUnique()
@NotNull IntListIterator iterator()
iterator
in interface IntIterable
iterator
in interface java.lang.Iterable<IntIterator>
@NotNull IntListIterator iterator(int from)
@NotNull IntListIterator iterator(int from, int to)
int getNextDifferentValueIndex(int curIndex)
j = -1 and for all k > i, a[k] = a[i]
;j > i and a[i] != a[j]
,a
represents the list.size()
if all values starting from the specified index are the same.java.util.List<java.lang.Integer> toList()