public abstract class AbstractBooleanList extends AbstractList
boolean
elements; abstract.
First see the package summary and javadoc tree view to get the broad picture.Modifier and Type | Field and Description |
---|---|
protected int |
size
The size of the list.
|
serialVersionUID
Modifier | Constructor and Description |
---|---|
protected |
AbstractBooleanList()
Makes this class non instantiable, but still let's others inherit from it.
|
Modifier and Type | Method and Description |
---|---|
void |
add(boolean element)
Appends the specified element to the end of this list.
|
void |
addAllOfFromTo(AbstractBooleanList other,
int from,
int to)
Appends the part of the specified list between
from (inclusive) and to (inclusive) to the receiver. |
void |
beforeInsert(int index,
boolean element)
Inserts the specified element before the specified position into the receiver.
|
void |
beforeInsertAllOfFromTo(int index,
AbstractBooleanList other,
int from,
int to)
Inserts the part of the specified list between
otherFrom (inclusive) and otherTo (inclusive) before the specified position into the receiver. |
protected void |
beforeInsertDummies(int index,
int length)
Inserts length dummy elements before the specified position into the receiver.
|
int |
binarySearch(boolean key)
Searches the receiver for the specified value using
the binary search algorithm.
|
int |
binarySearchFromTo(boolean key,
int from,
int to)
Searches the receiver for the specified value using
the binary search algorithm.
|
Object |
clone()
Returns a deep copy of the receiver.
|
boolean |
contains(boolean elem)
Returns true if the receiver contains the specified element.
|
void |
delete(boolean element)
Deletes the first element from the receiver that is identical to the specified element.
|
boolean[] |
elements()
Returns the elements currently stored, possibly including invalid elements between size and capacity.
|
AbstractBooleanList |
elements(boolean[] elements)
Sets the receiver's elements to be the specified array.
|
abstract 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.
|
void |
fillFromToWith(int from,
int to,
boolean val)
Sets the specified range of elements in the specified array to the specified value.
|
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.
|
protected abstract boolean |
getQuick(int index)
Returns the element at the specified position in the receiver; WARNING: Does not check preconditions.
|
int |
indexOf(boolean element)
Returns the index of the first occurrence of the specified
element.
|
int |
indexOfFromTo(boolean element,
int from,
int to)
Returns the index of the first occurrence of the specified
element.
|
int |
lastIndexOf(boolean element)
Returns the index of the last occurrence of the specified
element.
|
int |
lastIndexOfFromTo(boolean element,
int from,
int to)
Returns the index of the last occurrence of the specified
element.
|
AbstractBooleanList |
partFromTo(int from,
int to)
Returns a new list of the part of the receiver between
from , inclusive, and to , inclusive. |
boolean |
removeAll(AbstractBooleanList other)
Removes from the receiver all elements that are contained in the specified list.
|
void |
removeFromTo(int from,
int to)
Removes from the receiver all elements whose index is between
from , inclusive and to , inclusive. |
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.
|
void |
replaceFromToWithFromTo(int from,
int to,
AbstractBooleanList other,
int otherFrom,
int otherTo)
Replaces the part between
from (inclusive) and to (inclusive) with the other list's
part between otherFrom and otherTo . |
void |
replaceFromWith(int from,
Collection other)
Replaces the part of the receiver starting at
from (inclusive) with all the elements of the specified collection. |
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.
|
protected abstract 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.
|
protected void |
setSizeRaw(int newSize)
Sets the size of the receiver without modifying it otherwise.
|
void |
shuffleFromTo(int from,
int to)
Randomly permutes the part of the receiver between
from (inclusive) and to (inclusive). |
int |
size()
Returns the number of elements contained in the receiver.
|
AbstractBooleanList |
times(int times)
Returns a list which is a concatenation of
times times the receiver. |
protected static int |
toInt(boolean value)
Transforms a boolean value to an integer (false --> 0, true --> 1)
|
ArrayList |
toList()
Returns a
java.util.ArrayList containing all the elements in the receiver. |
String |
toString()
Returns a string representation of the receiver, containing
the String representation of each element.
|
addAllOf, beforeInsertAllOf, checkRange, checkRangeFromTo, clear, mergeSort, mergeSortFromTo, quickSort, quickSortFromTo, remove, setSize, shuffle, sort, sortFromTo, trimToSize
isEmpty
protected int size
protected AbstractBooleanList()
public void add(boolean element)
element
- element to be appended to this list.public void addAllOfFromTo(AbstractBooleanList other, int from, int to)
from
(inclusive) and to
(inclusive) to the receiver.other
- the list to be added to the receiver.from
- the index of the first element to be appended (inclusive).to
- the index of the last element to be appended (inclusive).IndexOutOfBoundsException
- index is out of range (other.size()>0 && (from<0 || from>to || to>=other.size())).public void beforeInsert(int index, boolean element)
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 void beforeInsertAllOfFromTo(int index, AbstractBooleanList other, int from, int to)
otherFrom
(inclusive) and otherTo
(inclusive) before the specified position into the receiver.
Shifts the element currently at that position (if any) and
any subsequent elements to the right.index
- index before which to insert first element from the specified list (must be in [0,size])..other
- list of which a part is to be inserted into the receiver.from
- the index of the first element to be inserted (inclusive).to
- the index of the last element to be inserted (inclusive).IndexOutOfBoundsException
- index is out of range (other.size()>0 && (from<0 || from>to || to>=other.size())).IndexOutOfBoundsException
- index is out of range (index < 0 || index > size()).protected void beforeInsertDummies(int index, int length)
beforeInsertDummies
in class AbstractList
index
- index before which to insert dummy elements (must be in [0,size])..length
- number of dummy elements to be inserted.IndexOutOfBoundsException
- if index < 0 || index > size().public int binarySearch(boolean key)
key
- the value to be searched for.Arrays
public int binarySearchFromTo(boolean key, int from, int to)
key
- the value to be searched for.from
- the leftmost search position, inclusive.to
- the rightmost search position, inclusive.Arrays
public Object clone()
clone
in class PersistentObject
public boolean contains(boolean elem)
element
- element whose presence in the receiver is to be tested.public void delete(boolean element)
element
- the element to be deleted.public boolean[] elements()
public AbstractBooleanList elements(boolean[] elements)
elements
- the new elements to be stored.public abstract void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.public boolean equals(Object otherObj)
public void fillFromToWith(int from, int to, boolean val)
from
- the index of the first element (inclusive) to be filled with the specified value.to
- the index of the last element (inclusive) to be filled with the specified value.val
- the value to be stored in the specified elements of the receiver.public boolean forEach(BooleanProcedure procedure)
procedure
- the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.public boolean get(int index)
index
- index of element to return.IndexOutOfBoundsException
- index is out of range (index
< 0 || index >= size()).protected abstract boolean getQuick(int index)
index
- index of element to return.public int indexOf(boolean element)
-1
if the receiver does not contain this element.element
- the element to be searched for.-1
if the element is not found.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.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 lastIndexOf(boolean element)
-1
if the receiver does not contain this element.element
- the element to be searched for.-1
if the element is not found.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.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 AbstractBooleanList partFromTo(int from, int to)
from
, inclusive, and to
, inclusive.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 boolean removeAll(AbstractBooleanList other)
other
- the other list.true
if the receiver changed as a result of the call.public void removeFromTo(int from, int to)
from
, inclusive and to
, inclusive. Shifts any succeeding
elements to the left (reduces their index).
This call booleanens the list by (to - from + 1) elements.removeFromTo
in class AbstractList
from
- index of first element to be removed.to
- index of last element to be removed.IndexOutOfBoundsException
- index is out of range (size()>0 && (from<0 || from>to || to>=size())).public void replaceFromToWithFrom(int from, int to, AbstractBooleanList other, int otherFrom)
from
(inclusive) and to
(inclusive),
with elements of other
, starting from otherFrom
(inclusive).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 void replaceFromToWithFromTo(int from, int to, AbstractBooleanList other, int otherFrom, int otherTo)
from
(inclusive) and to
(inclusive) with the other list's
part between otherFrom
and otherTo
.
Powerful (and tricky) method!
Both parts need not be of the same size (part A can both be smaller or larger than part B).
Parts may overlap.
Receiver and other list may (but most not) be identical.
If from > to
, then inserts other part before from
.from
- the first element of the receiver (inclusive)to
- the last element of the receiver (inclusive)other
- the other list (may be identical with receiver)otherFrom
- the first element of the other list (inclusive)otherTo
- the last element of the other list (inclusive)
Examples:
a=[0, 1, 2, 3, 4, 5, 6, 7] b=[50, 60, 70, 80, 90] a.R(...)=a.replaceFromToWithFromTo(...) a.R(3,5,b,0,4)-->[0, 1, 2, 50, 60, 70, 80, 90, 6, 7] a.R(1,6,b,0,4)-->[0, 50, 60, 70, 80, 90, 7] a.R(0,6,b,0,4)-->[50, 60, 70, 80, 90, 7] a.R(3,5,b,1,2)-->[0, 1, 2, 60, 70, 6, 7] a.R(1,6,b,1,2)-->[0, 60, 70, 7] a.R(0,6,b,1,2)-->[60, 70, 7] a.R(5,3,b,0,4)-->[0, 1, 2, 3, 4, 50, 60, 70, 80, 90, 5, 6, 7] a.R(5,0,b,0,4)-->[0, 1, 2, 3, 4, 50, 60, 70, 80, 90, 5, 6, 7] a.R(5,3,b,1,2)-->[0, 1, 2, 3, 4, 60, 70, 5, 6, 7] a.R(5,0,b,1,2)-->[0, 1, 2, 3, 4, 60, 70, 5, 6, 7] Extreme cases: a.R(5,3,b,0,0)-->[0, 1, 2, 3, 4, 50, 5, 6, 7] a.R(5,3,b,4,4)-->[0, 1, 2, 3, 4, 90, 5, 6, 7] a.R(3,5,a,0,1)-->[0, 1, 2, 0, 1, 6, 7] a.R(3,5,a,3,5)-->[0, 1, 2, 3, 4, 5, 6, 7] a.R(3,5,a,4,4)-->[0, 1, 2, 4, 6, 7] a.R(5,3,a,0,4)-->[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7] a.R(0,-1,b,0,4)-->[50, 60, 70, 80, 90, 0, 1, 2, 3, 4, 5, 6, 7] a.R(0,-1,a,0,4)-->[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7] a.R(8,0,a,0,4)-->[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4]
public void replaceFromWith(int from, Collection other)
from
(inclusive) with all the elements of the specified collection.
Does not alter the size of the receiver.
Replaces exactly Math.max(0,Math.min(size()-from, other.size())) elements.replaceFromWith
in class AbstractList
from
- the index at which to copy the first element from the specified collection.other
- Collection to replace part of the receiverIndexOutOfBoundsException
- index is out of range (index < 0 || index >= size()).public boolean retainAll(AbstractBooleanList other)
other
- the other list to test against.true
if the receiver changed as a result of the call.public void reverse()
reverse
in class AbstractList
public void set(int index, boolean element)
index
- index of element to replace.element
- element to be stored at the specified position.IndexOutOfBoundsException
- if index < 0 || index >= size().protected abstract void setQuick(int index, boolean element)
index
- index of element to replace.element
- element to be stored at the specified position.protected void setSizeRaw(int newSize)
public void shuffleFromTo(int from, int to)
from
(inclusive) and to
(inclusive).shuffleFromTo
in class AbstractList
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 int size()
size
in class AbstractCollection
public AbstractBooleanList times(int times)
times
times the receiver.times
- the number of times the receiver shall be copied.protected static int toInt(boolean value)
public ArrayList toList()
java.util.ArrayList
containing all the elements in the receiver.toList
in class AbstractCollection
public String toString()
toString
in class AbstractCollection
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.