public class BooleanImmutableList extends AbstractBooleanList implements BooleanList, java.util.RandomAccess, java.lang.Cloneable, java.io.Serializable
Instances of this class are immutable and (contrarily to mutable array-based list implementations) the backing array is not exposed. Instances can be built using a variety of methods, but note that constructors using an array will not make a defensive copy.
This class implements the bulk method getElements() using
high-performance system calls (e.g., System.arraycopy()) instead of
expensive loops.
AbstractBooleanList.BooleanRandomAccessSubList, AbstractBooleanList.BooleanSubList| Constructor and Description |
|---|
BooleanImmutableList(boolean[] a)
Creates a new immutable list using a given array.
|
BooleanImmutableList(boolean[] a,
int offset,
int length)
Creates a new immutable list and fills it with the elements of a given array.
|
BooleanImmutableList(BooleanCollection c)
Creates a new immutable list and fills it with a given type-specific collection.
|
BooleanImmutableList(it.unimi.dsi.fastutil.booleans.BooleanIterator i)
Creates a new immutable list and fills it with the elements returned by a type-specific iterator..
|
BooleanImmutableList(BooleanList l)
Creates a new immutable list and fills it with a given type-specific list.
|
BooleanImmutableList(java.util.Collection<? extends java.lang.Boolean> c)
Creates a new immutable list and fills it with a given collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(boolean k)
Deprecated.
|
boolean |
add(java.lang.Boolean k)
Deprecated.
|
void |
add(int index,
boolean k)
Deprecated.
|
void |
add(int index,
java.lang.Boolean k)
Deprecated.
|
boolean |
addAll(BooleanCollection c)
Deprecated.
|
boolean |
addAll(BooleanList c)
Deprecated.
|
boolean |
addAll(java.util.Collection<? extends java.lang.Boolean> c)
Deprecated.
|
boolean |
addAll(int index,
BooleanCollection c)
Deprecated.
|
boolean |
addAll(int index,
BooleanList c)
Deprecated.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Boolean> c)
Deprecated.
|
void |
addElements(int index,
boolean[] a,
int offset,
int length)
Deprecated.
|
void |
clear()
Deprecated.
|
BooleanImmutableList |
clone() |
int |
compareTo(BooleanImmutableList l)
Compares this immutable list to another immutable list.
|
int |
compareTo(java.util.List<? extends java.lang.Boolean> l)
Compares this list to another object.
|
boolean |
equals(BooleanImmutableList l)
Compares this type-specific immutable list to another one.
|
boolean |
equals(java.lang.Object o) |
void |
forEach(it.unimi.dsi.fastutil.booleans.BooleanConsumer action)
Performs the given action for each element of this type-specific
Iterable
until all elements have been processed or the action throws an
exception. |
boolean |
getBoolean(int index)
Returns the element at the specified position in this list.
|
void |
getElements(int from,
boolean[] a,
int offset,
int length)
Copies element of this type-specific list into the given array using optimized system calls.
|
int |
indexOf(boolean k)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
boolean |
isEmpty() |
int |
lastIndexOf(boolean k)
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
BooleanListIterator |
listIterator(int index)
Returns a type-specific list iterator on the list starting at a given index.
|
static BooleanImmutableList |
of()
Returns an empty immutable list.
|
static BooleanImmutableList |
of(boolean... init)
Creates an immutable list using a list of elements.
|
boolean |
rem(boolean k)
Deprecated.
|
java.lang.Boolean |
remove(int index)
Deprecated.
|
boolean |
remove(java.lang.Object k)
Deprecated.
|
boolean |
removeAll(BooleanCollection c)
Deprecated.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeBoolean(int index)
Deprecated.
|
void |
removeElements(int from,
int to)
Deprecated.
|
boolean |
removeIf(BooleanPredicate c)
Deprecated.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Boolean> c)
Deprecated.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Boolean> operator)
Deprecated.
|
boolean |
retainAll(BooleanCollection c)
Deprecated.
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
set(int index,
boolean k)
Deprecated.
|
java.lang.Boolean |
set(int index,
java.lang.Boolean k)
Deprecated.
|
void |
setElements(int index,
boolean[] a,
int offset,
int length)
Deprecated.
|
int |
size() |
void |
size(int size)
Deprecated.
|
void |
sort(it.unimi.dsi.fastutil.booleans.BooleanComparator comp)
Deprecated.
|
void |
sort(java.util.Comparator<? super java.lang.Boolean> comparator)
Deprecated.
|
it.unimi.dsi.fastutil.booleans.BooleanSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this list.
|
BooleanList |
subList(int from,
int to)
Returns a type-specific view of the portion of this list from the index
from, inclusive, to the index to, exclusive. |
boolean[] |
toArray(boolean[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
|
boolean[] |
toBooleanArray()
Returns a primitive type array containing the items of this collection.
|
void |
unstableSort(it.unimi.dsi.fastutil.booleans.BooleanComparator comp)
Deprecated.
|
void |
unstableSort(java.util.Comparator<? super java.lang.Boolean> comparator)
Deprecated.
|
addElements, contains, ensureIndex, ensureRestrictedIndex, hashCode, iterator, listIterator, peekBoolean, popBoolean, push, topBoolean, toStringcontains, containsAll, containsAll, toBooleanArrayfinalize, getClass, notify, notifyAll, wait, wait, waitadd, add, add, add, addAll, addAll, addAll, addElements, addElements, contains, get, indexOf, iterator, lastIndexOf, listIterator, of, of, of, remove, remove, removeBoolean, removeElements, replaceAll, replaceAll, set, set, setElements, setElements, setElements, size, sort, sort, unstableSort, unstableSortaddAll, addAll, clear, containsAll, hashCode, removeAll, retainAll, toArray, toArrayaddAll, contains, containsAll, rem, removeAll, removeIf, removeIf, retainAll, toBooleanArrayforEachpeek, pop, push, toppublic BooleanImmutableList(boolean[] a)
Note that this constructor does not perform a defensive copy.
a - the array that will be used to back this immutable list.public BooleanImmutableList(java.util.Collection<? extends java.lang.Boolean> c)
c - a collection that will be used to fill the immutable list.public BooleanImmutableList(BooleanCollection c)
c - a type-specific collection that will be used to fill the immutable list.public BooleanImmutableList(BooleanList l)
l - a type-specific list that will be used to fill the immutable list.public BooleanImmutableList(boolean[] a,
int offset,
int length)
a - an array whose elements will be used to fill the immutable list.offset - the first element to use.length - the number of elements to use.public BooleanImmutableList(it.unimi.dsi.fastutil.booleans.BooleanIterator i)
i - a type-specific iterator whose returned elements will fill the immutable list.public static BooleanImmutableList of()
of in interface BooleanListpublic static BooleanImmutableList of(boolean... init)
Note that this method does not perform a defensive copy.
of in interface BooleanListinit - a list of elements that will be used to initialize the list.public boolean getBoolean(int index)
BooleanListgetBoolean in interface BooleanListList.get(int)public int indexOf(boolean k)
BooleanListindexOf in interface BooleanListindexOf in class AbstractBooleanListList.indexOf(Object)public int lastIndexOf(boolean k)
BooleanListlastIndexOf in interface BooleanListlastIndexOf in class AbstractBooleanListList.lastIndexOf(Object)public int size()
size in interface java.util.Collection<java.lang.Boolean>size in interface java.util.List<java.lang.Boolean>size in class java.util.AbstractCollection<java.lang.Boolean>public boolean isEmpty()
isEmpty in interface it.unimi.dsi.fastutil.Stack<java.lang.Boolean>isEmpty in interface java.util.Collection<java.lang.Boolean>isEmpty in interface java.util.List<java.lang.Boolean>isEmpty in class java.util.AbstractCollection<java.lang.Boolean>public void getElements(int from,
boolean[] a,
int offset,
int length)
getElements in interface BooleanListgetElements in class AbstractBooleanListfrom - the start index (inclusive).a - the destination array.offset - the offset into the destination array where to store the first element copied.length - the number of elements to be copied.public void forEach(it.unimi.dsi.fastutil.booleans.BooleanConsumer action)
AbstractBooleanListIterable
until all elements have been processed or the action throws an
exception.forEach in interface BooleanIterableforEach in class AbstractBooleanListaction - the action to be performed for each element.Iterable.forEach(java.util.function.Consumer)public boolean[] toBooleanArray()
BooleanCollectiontoBooleanArray in interface BooleanCollectiontoBooleanArray in class AbstractBooleanListCollection.toArray()public boolean[] toArray(boolean[] a)
BooleanCollectionNote that, contrarily to Collection.toArray(Object[]), this
methods just writes all elements of this collection: no special
value will be added after the last one.
toArray in interface BooleanCollectiontoArray in class AbstractBooleanLista - if this array is big enough, it will be used to store this collection.Collection.toArray(Object[])public BooleanListIterator listIterator(int index)
AbstractBooleanListlistIterator in interface BooleanListlistIterator in interface java.util.List<java.lang.Boolean>listIterator in class AbstractBooleanListList.listIterator(int)public it.unimi.dsi.fastutil.booleans.BooleanSpliterator spliterator()
BooleanListList spliterators must report at least Spliterator.SIZED and Spliterator.ORDERED.
See List.spliterator() for more documentation on the requirements
of the returned spliterator.
spliterator in interface BooleanCollectionspliterator in interface BooleanIterablespliterator in interface BooleanListspliterator in interface java.lang.Iterable<java.lang.Boolean>spliterator in interface java.util.Collection<java.lang.Boolean>spliterator in interface java.util.List<java.lang.Boolean>public BooleanList subList(int from, int to)
from, inclusive, to the index to, exclusive.subList in interface BooleanListsubList in interface java.util.List<java.lang.Boolean>subList in class AbstractBooleanListList.subList(int,int)public BooleanImmutableList clone()
clone in class java.lang.Objectpublic boolean equals(BooleanImmutableList l)
l - a type-specific immutable list.public boolean equals(java.lang.Object o)
equals in interface java.util.Collection<java.lang.Boolean>equals in interface java.util.List<java.lang.Boolean>equals in class AbstractBooleanListpublic int compareTo(BooleanImmutableList l)
l - an immutable list.public int compareTo(java.util.List<? extends java.lang.Boolean> l)
AbstractBooleanListList, this method performs a lexicographical comparison; otherwise,
it throws a ClassCastException.compareTo in interface java.lang.Comparable<java.util.List<? extends java.lang.Boolean>>compareTo in class AbstractBooleanListl - a list.List, a negative integer,
zero, or a positive integer as this list is lexicographically less than, equal
to, or greater than the argument.@Deprecated
public final void add(int index,
boolean k)
AbstractBooleanListadd in interface BooleanListadd in class AbstractBooleanListList.add(int,Object)@Deprecated public final boolean add(boolean k)
AbstractBooleanListadd in interface BooleanCollectionadd in interface BooleanListadd in class AbstractBooleanListCollection.add(Object)@Deprecated public final boolean addAll(java.util.Collection<? extends java.lang.Boolean> c)
AbstractBooleanListaddAll in interface java.util.Collection<java.lang.Boolean>addAll in interface java.util.List<java.lang.Boolean>addAll in class AbstractBooleanList@Deprecated
public final boolean addAll(int index,
java.util.Collection<? extends java.lang.Boolean> c)
AbstractBooleanListaddAll in interface java.util.List<java.lang.Boolean>addAll in class AbstractBooleanList@Deprecated public final boolean removeBoolean(int index)
AbstractBooleanListremoveBoolean in interface BooleanListremoveBoolean in class AbstractBooleanListList.remove(int)@Deprecated public final boolean rem(boolean k)
AbstractBooleanListrem in interface BooleanCollectionrem in class AbstractBooleanListList.remove(Object)@Deprecated public final boolean removeAll(java.util.Collection<?> c)
AbstractBooleanCollectionremoveAll in interface java.util.Collection<java.lang.Boolean>removeAll in interface java.util.List<java.lang.Boolean>removeAll in class AbstractBooleanCollection@Deprecated public final boolean retainAll(java.util.Collection<?> c)
AbstractBooleanCollectionretainAll in interface java.util.Collection<java.lang.Boolean>retainAll in interface java.util.List<java.lang.Boolean>retainAll in class AbstractBooleanCollection@Deprecated public final boolean removeIf(java.util.function.Predicate<? super java.lang.Boolean> c)
BooleanCollectionremoveIf in interface BooleanCollectionremoveIf in interface java.util.Collection<java.lang.Boolean>@Deprecated public final boolean removeIf(BooleanPredicate c)
BooleanCollectionremoveIf in interface BooleanCollectionc - a predicate which returns true for elements to be
removed.true if any elements were removed.Collection.removeIf(java.util.function.Predicate)@Deprecated public final void replaceAll(java.util.function.UnaryOperator<java.lang.Boolean> operator)
BooleanListreplaceAll in interface BooleanListreplaceAll in interface java.util.List<java.lang.Boolean>@Deprecated
public final void add(int index,
java.lang.Boolean k)
BooleanListadd in interface BooleanListadd in interface java.util.List<java.lang.Boolean>@Deprecated public final boolean add(java.lang.Boolean k)
AbstractBooleanCollectionadd in interface BooleanCollectionadd in interface BooleanListadd in interface java.util.Collection<java.lang.Boolean>add in interface java.util.List<java.lang.Boolean>add in class AbstractBooleanCollection@Deprecated public final java.lang.Boolean remove(int index)
BooleanListremove in interface BooleanListremove in interface java.util.List<java.lang.Boolean>@Deprecated public final boolean remove(java.lang.Object k)
AbstractBooleanCollectionremove in interface BooleanCollectionremove in interface BooleanListremove in interface java.util.Collection<java.lang.Boolean>remove in interface java.util.List<java.lang.Boolean>remove in class AbstractBooleanCollection@Deprecated
public final java.lang.Boolean set(int index,
java.lang.Boolean k)
BooleanListset in interface BooleanListset in interface java.util.List<java.lang.Boolean>@Deprecated public final boolean addAll(BooleanCollection c)
AbstractBooleanListaddAll in interface BooleanCollectionaddAll in class AbstractBooleanListc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)@Deprecated public final boolean addAll(BooleanList c)
BooleanListaddAll in interface BooleanListList.addAll(Collection)@Deprecated
public final boolean addAll(int index,
BooleanCollection c)
BooleanListaddAll in interface BooleanListaddAll in class AbstractBooleanListList.addAll(int,java.util.Collection)@Deprecated
public final boolean addAll(int index,
BooleanList c)
BooleanListaddAll in interface BooleanListList.addAll(int,Collection)@Deprecated public final boolean removeAll(BooleanCollection c)
BooleanCollectionremoveAll in interface BooleanCollectionremoveAll in class AbstractBooleanCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)@Deprecated public final boolean retainAll(BooleanCollection c)
BooleanCollectionretainAll in interface BooleanCollectionretainAll in class AbstractBooleanCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)@Deprecated
public final boolean set(int index,
boolean k)
AbstractBooleanListset in interface BooleanListset in class AbstractBooleanListList.set(int,Object)@Deprecated public final void clear()
AbstractBooleanListclear in interface java.util.Collection<java.lang.Boolean>clear in interface java.util.List<java.lang.Boolean>clear in class AbstractBooleanList@Deprecated public final void size(int size)
BooleanListIf the specified size is smaller than the current size, the last elements are
discarded. Otherwise, they are filled with 0/null/false.
size in interface BooleanListsize in class AbstractBooleanListsize - the new size.@Deprecated
public final void removeElements(int from,
int to)
AbstractBooleanListThis is a trivial iterator-based based implementation. It is expected that implementations will override this method with a more optimized version.
removeElements in interface BooleanListremoveElements in class AbstractBooleanListfrom - the start index (inclusive).to - the end index (exclusive).@Deprecated
public final void addElements(int index,
boolean[] a,
int offset,
int length)
AbstractBooleanListThis is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
addElements in interface BooleanListaddElements in class AbstractBooleanListindex - the index at which to add elements.a - the array containing the elements.offset - the offset of the first element to add.length - the number of elements to add.@Deprecated
public final void setElements(int index,
boolean[] a,
int offset,
int length)
BooleanList
ListIterator iter = listIterator(index);
int i = 0;
while (i < length) {
iter.next();
iter.set(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.setElements in interface BooleanListsetElements in class AbstractBooleanListindex - the index at which to start setting elements.a - the array containing the elementsoffset - the offset of the first element to add.length - the number of elements to add.@Deprecated public final void sort(it.unimi.dsi.fastutil.booleans.BooleanComparator comp)
BooleanListPass null to sort using natural ordering.
sort in interface BooleanListList.sort(java.util.Comparator)@Deprecated public final void unstableSort(it.unimi.dsi.fastutil.booleans.BooleanComparator comp)
BooleanListPass null to sort using natural ordering.
This differs from List.sort(java.util.Comparator) in that the results are
not assured to be stable, but may be a bit faster.
Unless a subclass specifies otherwise, the results of the method if the list is concurrently modified during the sort are unspecified.
unstableSort in interface BooleanList@Deprecated public final void sort(java.util.Comparator<? super java.lang.Boolean> comparator)
BooleanListsort in interface BooleanListsort in interface java.util.List<java.lang.Boolean>@Deprecated public final void unstableSort(java.util.Comparator<? super java.lang.Boolean> comparator)
BooleanListunstableSort in interface BooleanList