public interface ReferenceBigList<K> extends BigList<K>, ReferenceCollection<K>
BigList
; provides some additional methods that use polymorphism to avoid (un)boxing.
Additionally, this interface strengthens iterator()
, listIterator()
,
listIterator(long)
and subList(long,long)
.
This interface specifies reference equality semantics (members will be compared equal with
==
instead of equals
), which may result in breaks in contract
if attempted to be used with non reference-equality semantics based BigList
s. For example, a
aReferenceBigList.equals(aObjectBigList)
may return different a different result then
aObjectBigList.equals(aReferenceBigList)
, in violation of equals
's contract
requiring it being symmetric.
Besides polymorphic methods, this interfaces specifies methods to copy into an array or remove contiguous sublists. Although the abstract implementation of this interface provides simple, one-by-one implementations of these methods, it is expected that concrete implementation override them with optimized versions.
List
Modifier and Type | Method and Description |
---|---|
default boolean |
addAll(long index,
ReferenceBigList<? extends K> l)
Inserts all of the elements in the specified type-specific big list into this type-specific big list at the specified position (optional operation).
|
default boolean |
addAll(long index,
ReferenceList<? extends K> l)
Inserts all of the elements in the specified type-specific list into this type-specific big list at the specified position (optional operation).
|
default boolean |
addAll(ReferenceBigList<? extends K> l)
Appends all of the elements in the specified type-specific big list to the end of this type-specific big list (optional operation).
|
default boolean |
addAll(ReferenceList<? extends K> l)
Appends all of the elements in the specified type-specific list to the end of this type-specific big list (optional operation).
|
void |
addElements(long index,
K[][] a)
Add (hopefully quickly) elements to this type-specific big list.
|
void |
addElements(long index,
K[][] a,
long offset,
long length)
Add (hopefully quickly) elements to this type-specific big list.
|
void |
getElements(long from,
java.lang.Object[][] a,
long offset,
long length)
Copies (hopefully quickly) elements of this type-specific big list into the given big array.
|
ObjectBigListIterator<K> |
iterator()
Returns a type-specific iterator on the elements of this list.
|
ObjectBigListIterator<K> |
listIterator()
Returns a type-specific big-list iterator on this type-specific big list.
|
ObjectBigListIterator<K> |
listIterator(long index)
Returns a type-specific list iterator on this type-specific big list starting at a given index.
|
void |
removeElements(long from,
long to)
Removes (hopefully quickly) elements of this type-specific big list.
|
default void |
setElements(K[][] a)
Set (hopefully quickly) elements to match the array given.
|
default void |
setElements(long index,
K[][] a)
Set (hopefully quickly) elements to match the array given.
|
default void |
setElements(long index,
K[][] a,
long offset,
long length)
Set (hopefully quickly) elements to match the array given.
|
default ObjectSpliterator<K> |
spliterator()
Returns a type-specific spliterator on the elements of this big-list.
|
ReferenceBigList<K> |
subList(long from,
long to)
Returns a type-specific view of the portion of this type-specific big list from the index
from , inclusive, to the index to , exclusive. |
add, addAll, get, indexOf, lastIndexOf, remove, set, size, size
ObjectBigListIterator<K> iterator()
iterator
in interface java.util.Collection<K>
iterator
in interface java.lang.Iterable<K>
iterator
in interface ObjectIterable<K>
iterator
in interface ReferenceCollection<K>
Collection.iterator()
Collection.iterator()
.ObjectBigListIterator<K> listIterator()
listIterator
in interface BigList<K>
BigList.listIterator()
BigList.listIterator()
.ObjectBigListIterator<K> listIterator(long index)
listIterator
in interface BigList<K>
index
- index of first element to be returned from the big-list iterator.BigList.listIterator(long)
BigList.listIterator(long)
.default ObjectSpliterator<K> spliterator()
BigList spliterators must report at least Spliterator.SIZED
and Spliterator.ORDERED
.
See List.spliterator()
for more documentation on the requirements
of the returned spliterator (despite BigList
not being a List
, most of the
same requirements apply.
spliterator
in interface java.util.Collection<K>
spliterator
in interface java.lang.Iterable<K>
spliterator
in interface ObjectIterable<K>
spliterator
in interface ReferenceCollection<K>
spliterator
method subclasses should override.Spliterator
for documentation on what binding policies mean).
RandomAccess
lists, this will return a spliterator
that calls the type-specific BigList.get(long)
method on the appropriate indexes.iterator()
.In either case, the spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, and Spliterator.ORDERED
.
Iterator
is an inherently linear API, the returned
spliterator will yield limited performance gains when run in parallel contexts, as the
returned spliterator's trySplit()
will have linear runtime.
For RandomAccess
lists, the parallel performance should
be reasonable assuming BigList.get(long)
is truly constant time like RandomAccess
suggests.
ReferenceBigList<K> subList(long from, long to)
from
, inclusive, to the index to
, exclusive.subList
in interface BigList<K>
from
- the starting element (inclusive).to
- the ending element (exclusive).BigList.subList(long,long)
BigList.subList(long,long)
.void getElements(long from, java.lang.Object[][] a, long offset, long length)
from
- the start index (inclusive).a
- the destination big array.offset
- the offset into the destination big array where to store the first element copied.length
- the number of elements to be copied.void removeElements(long from, long to)
from
- the start index (inclusive).to
- the end index (exclusive).void addElements(long index, K[][] a)
index
- the index at which to add elements.a
- the big array containing the elements.void addElements(long index, K[][] a, long offset, long length)
index
- the index at which to add elements.a
- the big array containing the elements.offset
- the offset of the first element to add.length
- the number of elements to add.default void setElements(K[][] a)
a
- the big array containing the elements.default void setElements(long index, K[][] a)
index
- the index at which to start setting elements.a
- the big array containing the elements.default void setElements(long index, K[][] a, long offset, long length)
ListIterator iter = listIterator(index); long i = 0; while (i < length) { iter.next(); iter.set(BigArrays.get(a, offset + i++); }However, the exact implementation may be more efficient, taking into account whether random access is faster or not, or at the discretion of subclasses, abuse internals.
index
- the index at which to start setting elements.a
- the big array containing the elements.offset
- the offset of the first element to add.length
- the number of elements to add.default boolean addAll(long index, ReferenceBigList<? extends K> l)
BigList.addAll(long,Collection)
getElements(long, java.lang.Object[][], long, long)
/addElements(long, K[][])
.default boolean addAll(ReferenceBigList<? extends K> l)
Collection.addAll(Collection)
BigList.size()
as first argument.default boolean addAll(long index, ReferenceList<? extends K> l)
BigList.addAll(long,Collection)
getElements(long, java.lang.Object[][], long, long)
/addElements(long, K[][])
.default boolean addAll(ReferenceList<? extends K> l)
Collection.addAll(Collection)
BigList.size()
as first argument.