public class BooleanArrayList extends AbstractBooleanList
boolean
elements; implemented with
arrays. First see the package summary and
javadoc tree view to get the broad picture.Constructor and Description |
---|
BooleanArrayList()
Constructs an empty list.
|
BooleanArrayList(boolean[] elements)
Constructs a list containing the specified elements.
|
BooleanArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(boolean element)
Appends the specified element to the end of this list.
|
void |
beforeInsert(int index,
boolean element)
Inserts the specified element before the specified position into the
receiver.
|
Object |
clone()
Returns a deep copy of the receiver.
|
BooleanArrayList |
copy()
Returns a deep copy of the receiver; uses
clone() and casts
the result. |
void |
countSortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending numerical order
(false < true).
|
boolean[] |
elements()
Returns the elements currently stored, including invalid elements between
size and capacity, if any.
|
AbstractBooleanList |
elements(boolean[] elements)
Sets the receiver's elements to be the specified array (not a copy of
it).
|
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of
elements without needing to allocate new internal memory.
|
boolean |
equals(Object otherObj)
Compares the specified Object with the receiver.
|
boolean |
forEach(BooleanProcedure procedure)
Applies a procedure to each element of the receiver, if any.
|
boolean |
get(int index)
Returns the element at the specified position in the receiver.
|
boolean |
getQuick(int index)
Returns the element at the specified position in the receiver;
WARNING: Does not check preconditions.
|
int |
indexOfFromTo(boolean element,
int from,
int to)
Returns the index of the first occurrence of the specified element.
|
int |
lastIndexOfFromTo(boolean element,
int from,
int to)
Returns the index of the last occurrence of the specified element.
|
void |
mergeSortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending order (
false < true).
|
AbstractBooleanList |
partFromTo(int from,
int to)
Returns a new list of the part of the receiver between
from ,
inclusive, and to , inclusive. |
void |
quickSortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending order (
false < true).
|
boolean |
removeAll(AbstractBooleanList other)
Removes from the receiver all elements that are contained in the
specified list.
|
void |
replaceFromToWithFrom(int from,
int to,
AbstractBooleanList other,
int otherFrom)
Replaces a number of elements in the receiver with the same number of
elements of another list.
|
boolean |
retainAll(AbstractBooleanList other)
Retains (keeps) only the elements in the receiver that are contained in
the specified other list.
|
void |
reverse()
Reverses the elements of the receiver.
|
void |
set(int index,
boolean element)
Replaces the element at the specified position in the receiver with the
specified element.
|
void |
setQuick(int index,
boolean element)
Replaces the element at the specified position in the receiver with the
specified element; WARNING: Does not check preconditions.
|
void |
shuffleFromTo(int from,
int to)
Randomly permutes the part of the receiver between
from
(inclusive) and to (inclusive). |
void |
sortFromTo(int from,
int to)
Sorts the specified range of the receiver into ascending order.
|
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size.
|
addAllOfFromTo, beforeInsertAllOfFromTo, binarySearch, binarySearchFromTo, contains, delete, fillFromToWith, indexOf, lastIndexOf, removeFromTo, replaceFromToWithFromTo, replaceFromWith, size, times, toList, toString
addAllOf, beforeInsertAllOf, clear, mergeSort, quickSort, remove, setSize, shuffle, sort
isEmpty
public BooleanArrayList()
public BooleanArrayList(boolean[] elements)
elements
- the array to be backed by the the constructed listpublic BooleanArrayList(int initialCapacity)
initialCapacity
- the number of elements the receiver can hold without
auto-expanding itself by allocating new internal memory.public void add(boolean element)
add
in class AbstractBooleanList
element
- element to be appended to this list.public void beforeInsert(int index, boolean element)
beforeInsert
in class AbstractBooleanList
index
- index before which the specified element is to be inserted
(must be in [0,size]).element
- element to be inserted.IndexOutOfBoundsException
- index is out of range (
index < 0 || index > size()).public Object clone()
clone
in class AbstractBooleanList
public BooleanArrayList copy()
clone()
and casts
the result.public void countSortFromTo(int from, int to)
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.public boolean[] elements()
elements
in class AbstractBooleanList
public AbstractBooleanList elements(boolean[] elements)
elements
in class AbstractBooleanList
elements
- the new elements to be stored.public void ensureCapacity(int minCapacity)
ensureCapacity
in class AbstractBooleanList
minCapacity
- the desired minimum capacity.public boolean equals(Object otherObj)
equals
in class AbstractBooleanList
otherObj
- the Object to be compared for equality with the receiver.public boolean forEach(BooleanProcedure procedure)
forEach
in class AbstractBooleanList
procedure
- the procedure to be applied. Stops iteration if the procedure
returns false, otherwise continues.public boolean get(int index)
get
in class AbstractBooleanList
index
- index of element to return.IndexOutOfBoundsException
- index is out of range (index < 0 || index >=
size()).public boolean getQuick(int index)
index
- index of element to return.public int indexOfFromTo(boolean element, int from, int to)
-1
if the receiver does not contain this element.
Searches between from
, inclusive and to
,
inclusive. Tests for identity.indexOfFromTo
in class AbstractBooleanList
element
- element to search for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.-1
if the element is not found.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public int lastIndexOfFromTo(boolean element, int from, int to)
-1
if the receiver does not contain this element.
Searches beginning at to
, inclusive until from
,
inclusive. Tests for identity.lastIndexOfFromTo
in class AbstractBooleanList
element
- element to search for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.-1
if the element is not found.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public void mergeSortFromTo(int from, int to)
mergeSortFromTo
in class AbstractList
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public AbstractBooleanList partFromTo(int from, int to)
from
,
inclusive, and to
, inclusive.partFromTo
in class AbstractBooleanList
from
- the index of the first element (inclusive).to
- the index of the last element (inclusive).IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public void quickSortFromTo(int from, int to)
quickSortFromTo
in class AbstractList
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public boolean removeAll(AbstractBooleanList other)
removeAll
in class AbstractBooleanList
other
- the other list.true
if the receiver changed as a result of the
call.public void replaceFromToWithFrom(int from, int to, AbstractBooleanList other, int otherFrom)
from
(inclusive) and to
(inclusive), with
elements of other
, starting from otherFrom
(inclusive).replaceFromToWithFrom
in class AbstractBooleanList
from
- the position of the first element to be replaced in the
receiverto
- the position of the last element to be replaced in the
receiverother
- list holding elements to be copied into the receiver.otherFrom
- position of first element within other list to be copied.public boolean retainAll(AbstractBooleanList other)
retainAll
in class AbstractBooleanList
other
- the other list to test against.true
if the receiver changed as a result of the
call.public void reverse()
reverse
in class AbstractBooleanList
public void set(int index, boolean element)
set
in class AbstractBooleanList
index
- index of element to replace.element
- element to be stored at the specified position.IndexOutOfBoundsException
- index is out of range (index < 0 || index >=
size()).public void setQuick(int index, boolean element)
index
- index of element to replace.element
- element to be stored at the specified position.public void shuffleFromTo(int from, int to)
from
(inclusive) and to
(inclusive).shuffleFromTo
in class AbstractBooleanList
from
- the index of the first element (inclusive) to be permuted.to
- the index of the last element (inclusive) to be permuted.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public void sortFromTo(int from, int to)
sortFromTo
in class AbstractList
from
- the index of the first element (inclusive) to be sorted.to
- the index of the last element (inclusive) to be sorted.IndexOutOfBoundsException
- index is out of range (
size()>0 && (from<0 || from>to || to>=size())
).public void trimToSize()
trimToSize
in class AbstractList
Jump to the Parallel Colt Homepage