Package com.google.protobuf
Class BooleanArrayList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.google.protobuf.AbstractProtobufList<java.lang.Boolean>
-
- com.google.protobuf.BooleanArrayList
-
- All Implemented Interfaces:
Internal.BooleanList
,Internal.ProtobufList<java.lang.Boolean>
,PrimitiveNonBoxingCollection
,java.lang.Iterable<java.lang.Boolean>
,java.util.Collection<java.lang.Boolean>
,java.util.List<java.lang.Boolean>
,java.util.RandomAccess
final class BooleanArrayList extends AbstractProtobufList<java.lang.Boolean> implements Internal.BooleanList, java.util.RandomAccess, PrimitiveNonBoxingCollection
An implementation ofInternal.BooleanList
on top of a primitive array.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean[]
array
The backing store for the list.private static boolean[]
EMPTY_ARRAY
private static BooleanArrayList
EMPTY_LIST
private int
size
The size of the list distinct from the length of the array.-
Fields inherited from class com.google.protobuf.AbstractProtobufList
DEFAULT_CAPACITY
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
BooleanArrayList()
Constructs a new mutableBooleanArrayList
with default capacity.private
BooleanArrayList(boolean[] other, int size, boolean isMutable)
Constructs a new mutableBooleanArrayList
containing the same elements asother
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, java.lang.Boolean element)
boolean
add(java.lang.Boolean element)
boolean
addAll(java.util.Collection<? extends java.lang.Boolean> collection)
void
addBoolean(boolean element)
Likeadd(Boolean)
but more efficient in that it doesn't box the element.private void
addBoolean(int index, boolean element)
Likeadd(int, Boolean)
but more efficient in that it doesn't box the element.boolean
contains(java.lang.Object element)
static BooleanArrayList
emptyList()
(package private) void
ensureCapacity(int minCapacity)
Ensures the backing array can fit at least minCapacity elements.private void
ensureIndexInRange(int index)
Ensures that the providedindex
is within the range of[0, size]
.boolean
equals(java.lang.Object o)
java.lang.Boolean
get(int index)
boolean
getBoolean(int index)
LikeList.get(int)
but more efficient in that it doesn't box the returned value.private static int
growSize(int previousSize)
int
hashCode()
int
indexOf(java.lang.Object element)
private java.lang.String
makeOutOfBoundsExceptionMessage(int index)
Internal.BooleanList
mutableCopyWithCapacity(int capacity)
Returns a mutable clone of this list with the specified capacity.java.lang.Boolean
remove(int index)
protected void
removeRange(int fromIndex, int toIndex)
java.lang.Boolean
set(int index, java.lang.Boolean element)
boolean
setBoolean(int index, boolean element)
LikeList.set(int, Object)
but more efficient in that it doesn't box the element.int
size()
-
Methods inherited from class com.google.protobuf.AbstractProtobufList
addAll, clear, ensureIsMutable, isModifiable, makeImmutable, remove, removeAll, retainAll
-
Methods inherited from class java.util.AbstractList
iterator, lastIndexOf, listIterator, listIterator, subList
-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.protobuf.Internal.ProtobufList
isModifiable, makeImmutable
-
-
-
-
Field Detail
-
EMPTY_ARRAY
private static final boolean[] EMPTY_ARRAY
-
EMPTY_LIST
private static final BooleanArrayList EMPTY_LIST
-
array
private boolean[] array
The backing store for the list.
-
size
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.
-
-
Method Detail
-
emptyList
public static BooleanArrayList emptyList()
-
removeRange
protected void removeRange(int fromIndex, int toIndex)
- Overrides:
removeRange
in classjava.util.AbstractList<java.lang.Boolean>
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
equals
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
equals
in classAbstractProtobufList<java.lang.Boolean>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
hashCode
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
hashCode
in classAbstractProtobufList<java.lang.Boolean>
-
mutableCopyWithCapacity
public Internal.BooleanList mutableCopyWithCapacity(int capacity)
Description copied from interface:Internal.BooleanList
Returns a mutable clone of this list with the specified capacity.- Specified by:
mutableCopyWithCapacity
in interfaceInternal.BooleanList
- Specified by:
mutableCopyWithCapacity
in interfaceInternal.ProtobufList<java.lang.Boolean>
-
get
public java.lang.Boolean get(int index)
- Specified by:
get
in interfacejava.util.List<java.lang.Boolean>
- Specified by:
get
in classjava.util.AbstractList<java.lang.Boolean>
-
getBoolean
public boolean getBoolean(int index)
Description copied from interface:Internal.BooleanList
LikeList.get(int)
but more efficient in that it doesn't box the returned value.- Specified by:
getBoolean
in interfaceInternal.BooleanList
-
indexOf
public int indexOf(java.lang.Object element)
- Specified by:
indexOf
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
indexOf
in classjava.util.AbstractList<java.lang.Boolean>
-
contains
public boolean contains(java.lang.Object element)
- Specified by:
contains
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
contains
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
contains
in classjava.util.AbstractCollection<java.lang.Boolean>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
size
in interfacejava.util.List<java.lang.Boolean>
- Specified by:
size
in classjava.util.AbstractCollection<java.lang.Boolean>
-
set
public java.lang.Boolean set(int index, java.lang.Boolean element)
- Specified by:
set
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
set
in classAbstractProtobufList<java.lang.Boolean>
-
setBoolean
public boolean setBoolean(int index, boolean element)
Description copied from interface:Internal.BooleanList
LikeList.set(int, Object)
but more efficient in that it doesn't box the element.- Specified by:
setBoolean
in interfaceInternal.BooleanList
-
add
public boolean add(java.lang.Boolean element)
- Specified by:
add
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
add
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
add
in classAbstractProtobufList<java.lang.Boolean>
-
add
public void add(int index, java.lang.Boolean element)
- Specified by:
add
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
add
in classAbstractProtobufList<java.lang.Boolean>
-
addBoolean
public void addBoolean(boolean element)
Likeadd(Boolean)
but more efficient in that it doesn't box the element.- Specified by:
addBoolean
in interfaceInternal.BooleanList
-
addBoolean
private void addBoolean(int index, boolean element)
Likeadd(int, Boolean)
but more efficient in that it doesn't box the element.
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.Boolean> collection)
- Specified by:
addAll
in interfacejava.util.Collection<java.lang.Boolean>
- Specified by:
addAll
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
addAll
in classAbstractProtobufList<java.lang.Boolean>
-
remove
public java.lang.Boolean remove(int index)
- Specified by:
remove
in interfacejava.util.List<java.lang.Boolean>
- Overrides:
remove
in classAbstractProtobufList<java.lang.Boolean>
-
ensureCapacity
void ensureCapacity(int minCapacity)
Ensures the backing array can fit at least minCapacity elements.
-
growSize
private static int growSize(int previousSize)
-
ensureIndexInRange
private void ensureIndexInRange(int index)
Ensures that the providedindex
is within the range of[0, size]
. Throws anIndexOutOfBoundsException
if it is not.- Parameters:
index
- the index to verify is in range
-
makeOutOfBoundsExceptionMessage
private java.lang.String makeOutOfBoundsExceptionMessage(int index)
-
-