cern.colt.list

## Class BooleanArrayList

- java.lang.Object
- - cern.colt.PersistentObject
  - - cern.colt.list.AbstractCollection
    - - cern.colt.list.AbstractList
      - - cern.colt.list.AbstractBooleanList
        - - cern.colt.list.BooleanArrayList

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

      public class BooleanArrayList
      extends AbstractBooleanList

  Resizable list holding `boolean` elements; implemented with arrays. First see the package summary and javadoc tree view to get the broad picture.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class cern.colt.PersistentObject

      `serialVersionUID`

  - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    Methods
    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.
    `java.lang.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(java.lang.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.

    - ### Methods inherited from class cern.colt.list.AbstractBooleanList

      `addAllOfFromTo, beforeInsertAllOfFromTo, binarySearch, binarySearchFromTo, contains, delete, fillFromToWith, indexOf, lastIndexOf, removeFromTo, replaceFromToWithFromTo, replaceFromWith, size, times, toList, toString`

    - ### Methods inherited from class cern.colt.list.AbstractList

      `addAllOf, beforeInsertAllOf, clear, mergeSort, quickSort, remove, setSize, shuffle, sort`

    - ### Methods inherited from class cern.colt.list.AbstractCollection

      `isEmpty`

    - ### Methods inherited from class java.lang.Object

      `getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BooleanArrayList

          public BooleanArrayList()

      Constructs an empty list.

    - #### BooleanArrayList

          public BooleanArrayList(boolean[] elements)

      Constructs a list containing the specified elements. The initial size and capacity of the list is the length of the array. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the specified array directly via the [] operator, be sure you know what you're doing.
      Parameters:
        `elements` - the array to be backed by the the constructed list

    - #### BooleanArrayList

          public BooleanArrayList(int initialCapacity)

      Constructs an empty list with the specified initial capacity.
      Parameters:
        `initialCapacity` - the number of elements the receiver can hold without auto-expanding itself by allocating new internal memory.

  - ### Method Detail

    - #### add

          public void add(boolean element)

      Appends the specified element to the end of this list.
      Overrides:
        `add` in class `AbstractBooleanList`
      Parameters:
        `element` - element to be appended to this list.

    - #### 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.
      Overrides:
        `beforeInsert` in class `AbstractBooleanList`
      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()`).

    - #### clone

          public java.lang.Object clone()

      Returns a deep copy of the receiver.
      Overrides:
        `clone` in class `AbstractBooleanList`
      Returns:
        a deep copy of the receiver.

    - #### copy

          public BooleanArrayList copy()

      Returns a deep copy of the receiver; uses `clone()` and casts the result.
      Returns:
        a deep copy of the receiver.

    - #### countSortFromTo

          public void countSortFromTo(int from,
                             int to)

      Sorts the specified range of the receiver into ascending numerical order (`false < true`). The sorting algorithm is a count sort. This algorithm offers guaranteed O(n) performance without auxiliary memory.
      Parameters:
        `from` - the index of the first element (inclusive) to be sorted.
        `to` - the index of the last element (inclusive) to be sorted.

    - #### elements

          public boolean[] elements()

      Returns the elements currently stored, including invalid elements between size and capacity, if any. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing.
      Overrides:
        `elements` in class `AbstractBooleanList`
      Returns:
        the elements currently stored.

    - #### elements

          public AbstractBooleanList elements(boolean[] elements)

      Sets the receiver's elements to be the specified array (not a copy of it). The size and capacity of the list is the length of the array. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the specified array directly via the [] operator, be sure you know what you're doing.
      Overrides:
        `elements` in class `AbstractBooleanList`
      Parameters:
        `elements` - the new elements to be stored.
      Returns:
        the receiver itself.

    - #### ensureCapacity

          public 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.
      Specified by:
        `ensureCapacity` in class `AbstractBooleanList`
      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:
        `equals` in class `AbstractBooleanList`
      Parameters:
        `otherObj` - the Object to be compared for equality with the receiver.
      Returns:
        true if the specified Object is equal to 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.
      Overrides:
        `forEach` in class `AbstractBooleanList`
      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.
      Overrides:
        `get` in class `AbstractBooleanList`
      Parameters:
        `index` - index of element to return.
      Throws:
        `java.lang.IndexOutOfBoundsException` - index is out of range (index < 0 || index >= size()).

    - #### getQuick

          public boolean getQuick(int index)

      Returns the element at the specified position in the receiver; WARNING: Does not check preconditions. Provided with invalid parameters this method may return invalid elements without throwing any exception! You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): `index >= 0 && index < size()`.
      Parameters:
        `index` - index of element to return.

    - #### indexOfFromTo

          public int indexOfFromTo(boolean element,
                          int from,
                          int to)

      Returns the index of the first occurrence of the specified element. Returns `-1` if the receiver does not contain this element. Searches between `from`, inclusive and `to`, inclusive. Tests for identity.
      Overrides:
        `indexOfFromTo` in class `AbstractBooleanList`
      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 `-1` if the element is not found.
      Throws:
        `java.lang.IndexOutOfBoundsException` - index is out of range (`size()>0 && (from<0 || from>to || to>=size())`).

    - #### lastIndexOfFromTo

          public int lastIndexOfFromTo(boolean element,
                              int from,
                              int to)

      Returns the index of the last occurrence of the specified element. Returns `-1` if the receiver does not contain this element. Searches beginning at `to`, inclusive until `from`, inclusive. Tests for identity.
      Overrides:
        `lastIndexOfFromTo` in class `AbstractBooleanList`
      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 `-1` if the element is not found.
      Throws:
        `java.lang.IndexOutOfBoundsException` - index is out of range (`size()>0 && (from<0 || from>to || to>=size())`).

    - #### mergeSortFromTo

          public void mergeSortFromTo(int from,
                             int to)

      Sorts the specified range of the receiver into ascending order (`false < true`). The sorting algorithm is not a mergesort, but rather a countsort. This algorithm offers guaranteed O(n) performance.
      Specified by:
        `mergeSortFromTo` in class `AbstractList`
      Parameters:
        `from` - the index of the first element (inclusive) to be sorted.
        `to` - the index of the last element (inclusive) to be sorted.
      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 between `from`, inclusive, and `to`, inclusive.
      Overrides:
        `partFromTo` in class `AbstractBooleanList`
      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())`).

    - #### quickSortFromTo

          public void quickSortFromTo(int from,
                             int to)

      Sorts the specified range of the receiver into ascending order (`false < true`). The sorting algorithm is not a quicksort, but rather a countsort. This algorithm offers guaranteed O(n) performance.
      Specified by:
        `quickSortFromTo` in class `AbstractList`
      Parameters:
        `from` - the index of the first element (inclusive) to be sorted.
        `to` - the index of the last element (inclusive) to be sorted.
      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.
      Overrides:
        `removeAll` in class `AbstractBooleanList`
      Parameters:
        `other` - the other list.
      Returns:
        `true` if the receiver changed as a result of the call.

    - #### 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, between `from` (inclusive) and `to` (inclusive), with elements of `other`, starting from `otherFrom` (inclusive).
      Overrides:
        `replaceFromToWithFrom` in class `AbstractBooleanList`
      Parameters:
        `from` - the position of the first element to be replaced in the receiver
        `to` - the position of the last element to be replaced in the receiver
        `other` - list holding elements to be copied into the receiver.
        `otherFrom` - position of first element within other list to be copied.

    - #### 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.
      Overrides:
        `retainAll` in class `AbstractBooleanList`
      Parameters:
        `other` - the other list to test against.
      Returns:
        `true` if 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.
      Overrides:
        `reverse` in class `AbstractBooleanList`

    - #### set

          public void set(int index,
                 boolean element)

      Replaces the element at the specified position in the receiver with the specified element.
      Overrides:
        `set` in class `AbstractBooleanList`
      Parameters:
        `index` - index of element to replace.
        `element` - element to be stored at the specified position.
      Throws:
        `java.lang.IndexOutOfBoundsException` - index is out of range (index < 0 || index >= size()).

    - #### setQuick

          public 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. Provided with invalid parameters this method may access invalid indexes without throwing any exception! You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): `index >= 0 && index < size()`.
      Parameters:
        `index` - index of element to replace.
        `element` - element to be stored at the specified position.

    - #### shuffleFromTo

          public void shuffleFromTo(int from,
                           int to)

      Randomly permutes the part of the receiver between `from` (inclusive) and `to` (inclusive).
      Overrides:
        `shuffleFromTo` in class `AbstractBooleanList`
      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())`).

    - #### sortFromTo

          public void sortFromTo(int from,
                        int to)

      Sorts the specified range of the receiver into ascending order. The sorting algorithm is countsort.
      Overrides:
        `sortFromTo` in class `AbstractList`
      Parameters:
        `from` - the index of the first element (inclusive) to be sorted.
        `to` - the index of the last element (inclusive) to be sorted.
      Throws:
        `java.lang.IndexOutOfBoundsException` - index is out of range (`size()>0 && (from<0 || from>to || to>=size())`).

    - #### trimToSize

          public void trimToSize()

      Trims the capacity of the receiver to be the receiver's current size. Releases any superfluos internal memory. An application can use this operation to minimize the storage of the receiver.
      Overrides:
        `trimToSize` in class `AbstractList`

Jump to the Colt Homepage