cern.colt.list.tboolean
Class AbstractBooleanList
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.list.AbstractCollection
-
- cern.colt.list.AbstractList
-
- cern.colt.list.tboolean.AbstractBooleanList
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
- Direct Known Subclasses:
- BooleanArrayList
public abstract class AbstractBooleanList extends AbstractList
Abstract base class for resizable lists holdingbooleanelements; abstract. First see the package summary and javadoc tree view to get the broad picture.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidadd(boolean element)Appends the specified element to the end of this list.voidaddAllOfFromTo(AbstractBooleanList other, int from, int to)Appends the part of the specified list betweenfrom(inclusive) andto(inclusive) to the receiver.voidbeforeInsert(int index, boolean element)Inserts the specified element before the specified position into the receiver.voidbeforeInsertAllOfFromTo(int index, AbstractBooleanList other, int from, int to)Inserts the part of the specified list betweenotherFrom(inclusive) andotherTo(inclusive) before the specified position into the receiver.intbinarySearch(boolean key)Searches the receiver for the specified value using the binary search algorithm.intbinarySearchFromTo(boolean key, int from, int to)Searches the receiver for the specified value using the binary search algorithm.java.lang.Objectclone()Returns a deep copy of the receiver.booleancontains(boolean elem)Returns true if the receiver contains the specified element.voiddelete(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.AbstractBooleanListelements(boolean[] elements)Sets the receiver's elements to be the specified array.abstract voidensureCapacity(int minCapacity)Ensures that the receiver can hold at least the specified number of elements without needing to allocate new internal memory.booleanequals(java.lang.Object otherObj)Compares the specified Object with the receiver.voidfillFromToWith(int from, int to, boolean val)Sets the specified range of elements in the specified array to the specified value.booleanforEach(BooleanProcedure procedure)Applies a procedure to each element of the receiver, if any.booleanget(int index)Returns the element at the specified position in the receiver.intindexOf(boolean element)Returns the index of the first occurrence of the specified element.intindexOfFromTo(boolean element, int from, int to)Returns the index of the first occurrence of the specified element.intlastIndexOf(boolean element)Returns the index of the last occurrence of the specified element.intlastIndexOfFromTo(boolean element, int from, int to)Returns the index of the last occurrence of the specified element.AbstractBooleanListpartFromTo(int from, int to)Returns a new list of the part of the receiver betweenfrom, inclusive, andto, inclusive.booleanremoveAll(AbstractBooleanList other)Removes from the receiver all elements that are contained in the specified list.voidremoveFromTo(int from, int to)Removes from the receiver all elements whose index is betweenfrom, inclusive andto, inclusive.voidreplaceFromToWithFrom(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.voidreplaceFromToWithFromTo(int from, int to, AbstractBooleanList other, int otherFrom, int otherTo)Replaces the part betweenfrom(inclusive) andto(inclusive) with the other list's part betweenotherFromandotherTo.voidreplaceFromWith(int from, java.util.Collection other)Replaces the part of the receiver starting atfrom(inclusive) with all the elements of the specified collection.booleanretainAll(AbstractBooleanList other)Retains (keeps) only the elements in the receiver that are contained in the specified other list.voidreverse()Reverses the elements of the receiver.voidset(int index, boolean element)Replaces the element at the specified position in the receiver with the specified element.voidshuffleFromTo(int from, int to)Randomly permutes the part of the receiver betweenfrom(inclusive) andto(inclusive).intsize()Returns the number of elements contained in the receiver.AbstractBooleanListtimes(int times)Returns a list which is a concatenation oftimestimes the receiver.java.util.ArrayListtoList()Returns ajava.util.ArrayListcontaining all the elements in the receiver.java.lang.StringtoString()Returns a string representation of the receiver, containing the String representation of each element.-
Methods inherited from class cern.colt.list.AbstractList
addAllOf, beforeInsertAllOf, clear, mergeSort, mergeSortFromTo, quickSort, quickSortFromTo, remove, setSize, shuffle, sort, sortFromTo, trimToSize
-
Methods inherited from class cern.colt.list.AbstractCollection
isEmpty
-
-
-
-
Method Detail
-
add
public void add(boolean element)
Appends the specified element to the end of this list.- Parameters:
element- element to be appended to this list.
-
addAllOfFromTo
public void addAllOfFromTo(AbstractBooleanList other, int from, int to)
Appends the part of the specified list betweenfrom(inclusive) andto(inclusive) to the receiver.- Parameters:
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).- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( other.size()>0 && (from<0 || from>to || to>=other.size()) ).
-
beforeInsert
public void beforeInsert(int index, boolean element)Inserts the specified element before the specified position into the receiver. Shifts the element currently at that position (if any) and any subsequent elements to the right.- Parameters:
index- index before which the specified element is to be inserted (must be in [0,size]).element- element to be inserted.- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( index < 0 || index > size()).
-
beforeInsertAllOfFromTo
public void beforeInsertAllOfFromTo(int index, AbstractBooleanList other, int from, int to)Inserts the part of the specified list betweenotherFrom(inclusive) andotherTo(inclusive) before the specified position into the receiver. Shifts the element currently at that position (if any) and any subsequent elements to the right.- Parameters:
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).- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( other.size()>0 && (from<0 || from>to || to>=other.size()) ).java.lang.IndexOutOfBoundsException- index is out of range ( index < 0 || index > size()).
-
binarySearch
public int binarySearch(boolean key)
Searches the receiver for the specified value using the binary search algorithm. The receiver must must be sorted (as by the sort method) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the receiver contains multiple elements equal to the specified object, there is no guarantee which instance will be found.- Parameters:
key- the value to be searched for.- Returns:
- index of the search key, if it is contained in the receiver; otherwise, (-(insertion point) - 1). The insertion point is defined as the the point at which the value would be inserted into the receiver: the index of the first element greater than the key, or receiver.size(), if all elements in the receiver are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
- See Also:
Arrays
-
binarySearchFromTo
public int binarySearchFromTo(boolean key, int from, int to)Searches the receiver for the specified value using the binary search algorithm. The receiver must must be sorted (as by the sort method) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the receiver contains multiple elements equal to the specified object, there is no guarantee which instance will be found.- Parameters:
key- the value to be searched for.from- the leftmost search position, inclusive.to- the rightmost search position, inclusive.- Returns:
- index of the search key, if it is contained in the receiver; otherwise, (-(insertion point) - 1). The insertion point is defined as the the point at which the value would be inserted into the receiver: the index of the first element greater than the key, or receiver.size(), if all elements in the receiver are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
- See Also:
Arrays
-
clone
public java.lang.Object clone()
Returns a deep copy of the receiver.- Overrides:
clonein classPersistentObject- Returns:
- a deep copy of the receiver.
-
contains
public boolean contains(boolean elem)
Returns true if the receiver contains the specified element.- Parameters:
elem- element whose presence in the receiver is to be tested.
-
delete
public void delete(boolean element)
Deletes the first element from the receiver that is identical to the specified element. Does nothing, if no such matching element is contained.- Parameters:
element- the element to be deleted.
-
elements
public boolean[] elements()
Returns the elements currently stored, possibly including invalid elements between size and capacity. WARNING: For efficiency reasons and to keep memory usage low, this method may decide not to copy the array. So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing.- Returns:
- the elements currently stored.
-
elements
public AbstractBooleanList elements(boolean[] elements)
Sets the receiver's elements to be the specified array. The size and capacity of the list is the length of the array. WARNING: For efficiency reasons and to keep memory usage low, this method may decide not to copy the array. So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing.- Parameters:
elements- the new elements to be stored.- Returns:
- the receiver itself.
-
ensureCapacity
public 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. If necessary, allocates new internal memory and increases the capacity of the receiver.- Parameters:
minCapacity- the desired minimum capacity.
-
equals
public boolean equals(java.lang.Object otherObj)
Compares the specified Object with the receiver. Returns true if and only if the specified Object is also an ArrayList of the same type, both Lists have the same size, and all corresponding pairs of elements in the two Lists are identical. In other words, two Lists are defined to be equal if they contain the same elements in the same order.- Overrides:
equalsin classjava.lang.Object- Parameters:
otherObj- the Object to be compared for equality with the receiver.- Returns:
- true if the specified Object is equal to the receiver.
-
fillFromToWith
public void fillFromToWith(int from, int to, boolean val)Sets the specified range of elements in the specified array to the specified value.- Parameters:
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.
-
forEach
public boolean forEach(BooleanProcedure procedure)
Applies a procedure to each element of the receiver, if any. Starts at index 0, moving rightwards.- Parameters:
procedure- the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.- Returns:
- false if the procedure stopped before all elements where iterated over, true otherwise.
-
get
public boolean get(int index)
Returns the element at the specified position in the receiver.- Parameters:
index- index of element to return.- Throws:
java.lang.IndexOutOfBoundsException- index is out of range (index < 0 || index >= size()).
-
indexOf
public int indexOf(boolean element)
Returns the index of the first occurrence of the specified element. Returns-1if the receiver does not contain this element.- Parameters:
element- the element to be searched for.- Returns:
- the index of the first occurrence of the element in the receiver;
returns
-1if the element is not found.
-
indexOfFromTo
public int indexOfFromTo(boolean element, int from, int to)Returns the index of the first occurrence of the specified element. Returns-1if the receiver does not contain this element. Searches betweenfrom, inclusive andto, inclusive. Tests for identity.- Parameters:
element- element to search for.from- the leftmost search position, inclusive.to- the rightmost search position, inclusive.- Returns:
- the index of the first occurrence of the element in the receiver;
returns
-1if the element is not found. - Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( size()>0 && (from<0 || from>to || to>=size()) ).
-
lastIndexOf
public int lastIndexOf(boolean element)
Returns the index of the last occurrence of the specified element. Returns-1if the receiver does not contain this element.- Parameters:
element- the element to be searched for.- Returns:
- the index of the last occurrence of the element in the receiver;
returns
-1if the element is not found.
-
lastIndexOfFromTo
public int lastIndexOfFromTo(boolean element, int from, int to)Returns the index of the last occurrence of the specified element. Returns-1if the receiver does not contain this element. Searches beginning atto, inclusive untilfrom, inclusive. Tests for identity.- Parameters:
element- element to search for.from- the leftmost search position, inclusive.to- the rightmost search position, inclusive.- Returns:
- the index of the last occurrence of the element in the receiver;
returns
-1if the element is not found. - Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( size()>0 && (from<0 || from>to || to>=size()) ).
-
partFromTo
public AbstractBooleanList partFromTo(int from, int to)
Returns a new list of the part of the receiver betweenfrom, inclusive, andto, inclusive.- Parameters:
from- the index of the first element (inclusive).to- the index of the last element (inclusive).- Returns:
- a new list
- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( size()>0 && (from<0 || from>to || to>=size()) ).
-
removeAll
public boolean removeAll(AbstractBooleanList other)
Removes from the receiver all elements that are contained in the specified list. Tests for identity.- Parameters:
other- the other list.- Returns:
trueif the receiver changed as a result of the call.
-
removeFromTo
public void removeFromTo(int from, int to)Removes from the receiver all elements whose index is betweenfrom, inclusive andto, inclusive. Shifts any succeeding elements to the left (reduces their index). This call booleanens the list by (to - from + 1) elements.- Specified by:
removeFromToin classAbstractList- Parameters:
from- index of first element to be removed.to- index of last element to be removed.- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( size()>0 && (from<0 || from>to || to>=size()) ).
-
replaceFromToWithFrom
public 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. Replaces elements in the receiver, betweenfrom(inclusive) andto(inclusive), with elements ofother, starting fromotherFrom(inclusive).- Parameters:
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.
-
replaceFromToWithFromTo
public void replaceFromToWithFromTo(int from, int to, AbstractBooleanList other, int otherFrom, int otherTo)Replaces the part betweenfrom(inclusive) andto(inclusive) with the other list's part betweenotherFromandotherTo. 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. Iffrom > to, then inserts other part beforefrom.- Parameters:
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]
-
replaceFromWith
public void replaceFromWith(int from, java.util.Collection other)Replaces the part of the receiver starting atfrom(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.- Specified by:
replaceFromWithin classAbstractList- Parameters:
from- the index at which to copy the first element from the specified collection.other- Collection to replace part of the receiver- Throws:
java.lang.IndexOutOfBoundsException- index is out of range (index < 0 || index >= size()).
-
retainAll
public boolean retainAll(AbstractBooleanList other)
Retains (keeps) only the elements in the receiver that are contained in the specified other list. In other words, removes from the receiver all of its elements that are not contained in the specified other list.- Parameters:
other- the other list to test against.- Returns:
trueif the receiver changed as a result of the call.
-
reverse
public void reverse()
Reverses the elements of the receiver. Last becomes first, second last becomes second first, and so on.- Specified by:
reversein classAbstractList
-
set
public void set(int index, boolean element)Replaces the element at the specified position in the receiver with the specified element.- Parameters:
index- index of element to replace.element- element to be stored at the specified position.- Throws:
java.lang.IndexOutOfBoundsException- if index < 0 || index >= size().
-
shuffleFromTo
public void shuffleFromTo(int from, int to)Randomly permutes the part of the receiver betweenfrom(inclusive) andto(inclusive).- Specified by:
shuffleFromToin classAbstractList- Parameters:
from- the index of the first element (inclusive) to be permuted.to- the index of the last element (inclusive) to be permuted.- Throws:
java.lang.IndexOutOfBoundsException- index is out of range ( size()>0 && (from<0 || from>to || to>=size()) ).
-
size
public int size()
Returns the number of elements contained in the receiver.- Specified by:
sizein classAbstractCollection- Returns:
- the number of elements contained in the receiver.
-
times
public AbstractBooleanList times(int times)
Returns a list which is a concatenation oftimestimes the receiver.- Parameters:
times- the number of times the receiver shall be copied.
-
toList
public java.util.ArrayList toList()
Returns ajava.util.ArrayListcontaining all the elements in the receiver.- Specified by:
toListin classAbstractCollection
-
toString
public java.lang.String toString()
Returns a string representation of the receiver, containing the String representation of each element.- Overrides:
toStringin classAbstractCollection
-
-
DMelt 3.0 © DataMelt by jWork.ORG