public class ReadOnlyConstantList
extends java.lang.Object
implements java.util.List
| Constructor and Description |
|---|
ReadOnlyConstantList(int size,
java.lang.Object value)
Create a read only list that always return the same
value value for every index. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
java.lang.Object element)
Modification of the underlying array or bitset is forbidden.
|
boolean |
add(java.lang.Object o)
Modification of the underlying array or bitset is forbidden.
|
boolean |
addAll(java.util.Collection c)
Modification of the underlying array or bitset is forbidden.
|
boolean |
addAll(int index,
java.util.Collection c)
Modification of the underlying array or bitset is forbidden.
|
void |
clear()
Modification of the underlying array or bitset is forbidden.
|
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection c) |
java.lang.Object |
get(int index)
get will return the element at index + startidx of the underlying array or bitset.
|
int |
indexOf(java.lang.Object o) |
boolean |
isEmpty() |
java.util.Iterator |
iterator() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator |
listIterator() |
java.util.ListIterator |
listIterator(int index) |
java.lang.Object |
remove(int index)
Modification of the underlying array or bitset is forbidden.
|
boolean |
remove(java.lang.Object o)
Modification of the underlying array or bitset is forbidden.
|
boolean |
removeAll(java.util.Collection c) |
void |
replaceAll(java.util.function.UnaryOperator operator)
Modification of the underlying array or bitset is forbidden.
|
boolean |
retainAll(java.util.Collection c) |
java.lang.Object |
set(int index,
java.lang.Object element)
Modification of the underlying array or bitset is forbidden.
|
int |
size() |
void |
sort(java.util.Comparator c)
Modification of the underlying array or bitset is forbidden.
|
java.util.Spliterator |
spliterator() |
java.util.List |
subList(int fromIndex,
int toIndex)
create a new Read Only subList from existing one, backed by the original array.
|
java.lang.Object[] |
toArray()
creates a new long/double/String/boolean array from the current subList (deep copy).
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
creates a new long/double/String/boolean array from the current subList (deep copy).
|
public ReadOnlyConstantList(int size,
java.lang.Object value)
value value for every index.size - List sizepublic int indexOf(java.lang.Object o)
indexOf in interface java.util.Listpublic int size()
size in interface java.util.Collectionsize in interface java.util.Listpublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in interface java.util.Listpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collectioncontains in interface java.util.Listpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Listpublic boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in interface java.util.Listpublic boolean remove(java.lang.Object o)
remove in interface java.util.Collectionremove in interface java.util.Listpublic boolean addAll(java.util.Collection c)
addAll in interface java.util.CollectionaddAll in interface java.util.Listpublic boolean addAll(int index,
java.util.Collection c)
addAll in interface java.util.Listpublic void replaceAll(java.util.function.UnaryOperator operator)
replaceAll in interface java.util.Listpublic void sort(java.util.Comparator c)
sort in interface java.util.Listpublic void clear()
clear in interface java.util.Collectionclear in interface java.util.Listpublic java.lang.Object get(int index)
get in interface java.util.Listindex - cannot be less than 0 or greater than list lengthpublic java.lang.Object set(int index,
java.lang.Object element)
set in interface java.util.Listpublic void add(int index,
java.lang.Object element)
add in interface java.util.Listpublic java.lang.Object remove(int index)
remove in interface java.util.Listpublic int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.Listpublic java.util.ListIterator listIterator()
listIterator in interface java.util.Listpublic java.util.ListIterator listIterator(int index)
listIterator in interface java.util.Listpublic java.util.List subList(int fromIndex,
int toIndex)
fromIndex, inclusive, and toIndex, exclusive. (If
fromIndex and toIndex are equal, the returned list is
empty.)subList in interface java.util.Listpublic java.util.Spliterator spliterator()
spliterator in interface java.lang.Iterablespliterator in interface java.util.Collectionspliterator in interface java.util.Listpublic boolean retainAll(java.util.Collection c)
retainAll in interface java.util.CollectionretainAll in interface java.util.Listpublic boolean removeAll(java.util.Collection c)
removeAll in interface java.util.CollectionremoveAll in interface java.util.Listpublic boolean containsAll(java.util.Collection c)
containsAll in interface java.util.CollectioncontainsAll in interface java.util.Listpublic java.lang.Object[] toArray(java.lang.Object[] a)
a is not big enough, toArray allocates and returns a new arraytoArray in interface java.util.CollectiontoArray in interface java.util.Listpublic java.lang.Object[] toArray()
toArray in interface java.util.CollectiontoArray in interface java.util.List