Top Description Fields Constructors Methods
com.google.protobuf

pack-priv final Class BooleanArrayList

extends AbstractProtobufList<Boolean>
implements BooleanList, RandomAccess, PrimitiveNonBoxingCollection
Class Inheritance
All Implemented Interfaces
com.google.protobuf.PrimitiveNonBoxingCollection, java.util.RandomAccess, com.google.protobuf.Internal.BooleanList, com.google.protobuf.Internal.ProtobufList, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Static Imports
com.google.protobuf.Internal.checkNotNull

An implementation of BooleanList on top of a primitive array.
Author
[email protected] (Daniel Weis)

Field Summary

Modifier and TypeField and Description
private boolean[]
array

The backing store for the list.

private static final BooleanArrayList
private int
size

The size of the list distinct from the length of the array.

Inherited from com.google.protobuf.AbstractProtobufList:
DEFAULT_CAPACITY

Constructor Summary

AccessConstructor and Description
pack-priv
BooleanArrayList()

Constructs a new mutable BooleanArrayList with default capacity.

private
BooleanArrayList(boolean[] other, int size)

Constructs a new mutable BooleanArrayList containing the same elements as other.

Method Summary

Modifier and TypeMethod and Description
public void
add(int
index at which the specified element is to be inserted
index
,
Boolean
element to be inserted
element
)

Overrides com.google.protobuf.AbstractProtobufList.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).
public boolean
addAll(Collection<? extends Boolean>
collection containing elements to be added to this list
collection
)

Overrides com.google.protobuf.AbstractProtobufList.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
public void
addBoolean(boolean element)

Implements com.google.protobuf.Internal.BooleanList.addBoolean.

Like add(Boolean) but more efficient in that it doesn't box the element.
private void
addBoolean(int index, boolean element)

Like add(int, Boolean) but more efficient in that it doesn't box the element.

public static BooleanArrayList
private void
ensureIndexInRange(int
the index to verify is in range
index
)

Ensures that the provided index is within the range of [0, size].

public boolean
equals(Object
the object to be compared for equality with this list
o
)

Overrides com.google.protobuf.AbstractProtobufList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.
public Boolean
get(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.
public boolean
getBoolean(int index)

Implements com.google.protobuf.Internal.BooleanList.getBoolean.

Like get(int) but more efficient in that it doesn't box the returned value.
public int
private String
public Internal.BooleanList
public boolean
remove(Object
element to be removed from this list, if present
o
)

Overrides com.google.protobuf.AbstractProtobufList.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).
public Boolean
remove(int
the index of the element to be removed
index
)

Overrides com.google.protobuf.AbstractProtobufList.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).
protected void
removeRange(int
index of first element to be removed
fromIndex
,
int
index after last element to be removed
toIndex
)

Overrides java.util.AbstractList.removeRange.

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
public Boolean
set(int
index of the element to replace
index
,
Boolean
element to be stored at the specified position
element
)

Overrides com.google.protobuf.AbstractProtobufList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public boolean
setBoolean(int index, boolean element)

Implements com.google.protobuf.Internal.BooleanList.setBoolean.

Like set(int, Object) but more efficient in that it doesn't box the element.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
Inherited from com.google.protobuf.AbstractProtobufList:
addaddAllclearensureIsMutableisModifiablemakeImmutableremoveAllretainAll

Field Detail

arrayback to summary
private boolean[] array

The backing store for the list.

EMPTY_LISTback to summary
private static final BooleanArrayList EMPTY_LIST
sizeback to summary
private int size

The size of the list distinct from the length of the array. That is, it is the number of elements set in the list.

Constructor Detail

BooleanArrayListback to summary
pack-priv BooleanArrayList()

Constructs a new mutable BooleanArrayList with default capacity.

BooleanArrayListback to summary
private BooleanArrayList(boolean[] other, int size)

Constructs a new mutable BooleanArrayList containing the same elements as other.

Method Detail

addback to summary
public void add(int index, Boolean element)

Overrides com.google.protobuf.AbstractProtobufList.add.

Implements java.util.List.add.

Doc from java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
index:int

index at which the specified element is to be inserted

element:Boolean

element to be inserted

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends Boolean> collection)

Overrides com.google.protobuf.AbstractProtobufList.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Doc from java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Parameters
collection:Collection<? extends Boolean>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

Annotations
@Override
addBooleanback to summary
public void addBoolean(boolean element)

Implements com.google.protobuf.Internal.BooleanList.addBoolean.

Like add(Boolean) but more efficient in that it doesn't box the element.

Annotations
@Override
addBooleanback to summary
private void addBoolean(int index, boolean element)

Like add(int, Boolean) but more efficient in that it doesn't box the element.

emptyListback to summary
public static BooleanArrayList emptyList()
ensureIndexInRangeback to summary
private void ensureIndexInRange(int index)

Ensures that the provided index is within the range of [0, size]. Throws an IndexOutOfBoundsException if it is not.

Parameters
index:int

the index to verify is in range

equalsback to summary
public boolean equals(Object o)

Overrides com.google.protobuf.AbstractProtobufList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.List.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if Objects.equals(e1, e2).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters
o:Object

the object to be compared for equality with this list

Returns:boolean

true if the specified object is equal to this list

Annotations
@Override
getback to summary
public Boolean get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Parameters
index:int

index of the element to return

Returns:Boolean

the element at the specified position in this list

Annotations
@Override
getBooleanback to summary
public boolean getBoolean(int index)

Implements com.google.protobuf.Internal.BooleanList.getBoolean.

Doc from com.google.protobuf.Internal.BooleanList.getBoolean.

Like get(int) but more efficient in that it doesn't box the returned value.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides com.google.protobuf.AbstractProtobufList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.List.hashCode.

Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:

int hashCode = 1;
    for (E e : list)
        hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object#hashCode.
Returns:int

the hash code value for this list

Annotations
@Override
makeOutOfBoundsExceptionMessageback to summary
private String makeOutOfBoundsExceptionMessage(int index)
mutableCopyWithCapacityback to summary
public Internal.BooleanList mutableCopyWithCapacity(int capacity)

Implements com.google.protobuf.Internal.BooleanList.mutableCopyWithCapacity, com.google.protobuf.Internal.ProtobufList.mutableCopyWithCapacity.

Doc from com.google.protobuf.Internal.BooleanList.mutableCopyWithCapacity.

Returns a mutable clone of this list with the specified capacity.

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides com.google.protobuf.AbstractProtobufList.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Doc from java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that Objects.equals(o, get(i)) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

Parameters
o:Object

element to be removed from this list, if present

Returns:boolean

true if this list contained the specified element

Annotations
@Override
removeback to summary
public Boolean remove(int index)

Overrides com.google.protobuf.AbstractProtobufList.remove.

Implements java.util.List.remove.

Doc from java.util.List.remove.

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters
index:int

the index of the element to be removed

Returns:Boolean

the element previously at the specified position

Annotations
@Override
removeRangeback to summary
protected void removeRange(int fromIndex, int toIndex)

Overrides java.util.AbstractList.removeRange.

Doc from java.util.AbstractList.removeRange.

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)

This method is called by the clear operation on this list and its subLists. Overriding this method to take advantage of the internals of the list implementation can substantially improve the performance of the clear operation on this list and its subLists.

Parameters
fromIndex:int

index of first element to be removed

toIndex:int

index after last element to be removed

Annotations
@Override
setback to summary
public Boolean set(int index, Boolean element)

Overrides com.google.protobuf.AbstractProtobufList.set.

Implements java.util.List.set.

Doc from java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

index of the element to replace

element:Boolean

element to be stored at the specified position

Returns:Boolean

the element previously at the specified position

Annotations
@Override
setBooleanback to summary
public boolean setBoolean(int index, boolean element)

Implements com.google.protobuf.Internal.BooleanList.setBoolean.

Doc from com.google.protobuf.Internal.BooleanList.setBoolean.

Like set(int, Object) but more efficient in that it doesn't box the element.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override