ByteArrayList

public class ByteArrayList
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.ByteArrayList


A class to represent a lightweight byte array. The goal of this class is to avoid the significant space overhead of using Java classes. See, for instance: http://benjchristensen.com/2008/05/27/java-memory-usage-ints/

Summary

Public constructors

ByteArrayList()

Constructs an empty list with an initial capacity of 128 bytes and growth factor of 2.0

ByteArrayList(int defaultSize)

Constructs an empty list with the specified initial capacity, and with a growth factor of 2.0

ByteArrayList(int defaultSize, float growthFactor)

Constructs an empty list with the specified initial capacity and growth factor

Public methods

boolean add(byte b)

Appends the specified element to the end of this list

boolean addAll(byte[] src)

Appends the full contents of the supplied byte[] to the list.

boolean addAll(byte[] src, int srcOffset, int length)

Appends the specified contents of the supplied byte[] to the list.

boolean addall(ByteArrayList src)

Appends the full contents of the supplied ByteArrayList to the list.

void clear()

Removes all of the elements from this list.

void ensureCapacity(int minCapacity)

Increases the capacity of this ByteArrayList instance, if necessary, to ensure that it can hold at least the number of bytes specified by the minimum capacity argument.

boolean equals(Object other)

byte get(int idx)

Returns the element at the specified position in this list

byte[] getContents()

Returns a copy of the contents of this ByteArrayList as a byte[].

int hashCode()

boolean isEmpty()

Returns true if this list contains no bytes

byte set(int idx, byte b)

Replaces the element at the specified position in this list with the specified element

int size()

Returns the number of bytes in this list

void trimToSize()

Trims the capacity of this ByteArrayList instance to be the list's current size.

Public constructors

ByteArrayList

ByteArrayList ()

Constructs an empty list with an initial capacity of 128 bytes and growth factor of 2.0

ByteArrayList

ByteArrayList (int defaultSize)

Constructs an empty list with the specified initial capacity, and with a growth factor of 2.0

Parameters
defaultSize int: The initial capacity of the list, in bytes

ByteArrayList

ByteArrayList (int defaultSize, 
                float growthFactor)

Constructs an empty list with the specified initial capacity and growth factor

Parameters
defaultSize int: The initial capacity of the list, in bytes

growthFactor float: The factor by which the capacity is multiplied when the list needs to auto-resize. Must be >= 1.1f.

Public methods

add

boolean add (byte b)

Appends the specified element to the end of this list

Parameters
b byte: The byte to append to the list

Returns
boolean true

addAll

boolean addAll (byte[] src)

Appends the full contents of the supplied byte[] to the list.

Parameters
src byte: The byte[] to append contents from

Returns
boolean true

addAll

boolean addAll (byte[] src, 
                int srcOffset, 
                int length)

Appends the specified contents of the supplied byte[] to the list.

Parameters
src byte: The byte[] to append contents from

srcOffset int: The index of first element of src to append

length int: The quantity of bytes to append to the list

Returns
boolean true

addall

boolean addall (ByteArrayList src)

Appends the full contents of the supplied ByteArrayList to the list.

Parameters
src ByteArrayList: The ByteArrayList to append contents from

Returns
boolean true

clear

void clear ()

Removes all of the elements from this list.

ensureCapacity

void ensureCapacity (int minCapacity)

Increases the capacity of this ByteArrayList instance, if necessary, to ensure that it can hold at least the number of bytes specified by the minimum capacity argument.

Parameters
minCapacity int: The minimum capacity to ensure storage for, in bytes

equals

boolean equals (Object other)

Parameters
other Object

Returns
boolean

get

byte get (int idx)

Returns the element at the specified position in this list

Parameters
idx int: The index to return

Returns
byte

getContents

byte[] getContents ()

Returns a copy of the contents of this ByteArrayList as a byte[].

Returns
byte[] A byte[] copy of the list contents

hashCode

int hashCode ()

Returns
int

isEmpty

boolean isEmpty ()

Returns true if this list contains no bytes

Returns
boolean

set

byte set (int idx, 
                byte b)

Replaces the element at the specified position in this list with the specified element

Parameters
idx int: The index to replace

b byte: The byte to replace at that index

Returns
byte

size

int size ()

Returns the number of bytes in this list

Returns
int

trimToSize

void trimToSize ()

Trims the capacity of this ByteArrayList instance to be the list's current size.