to top
public class

ByteArrayList

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

Class Overview

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, int srcOffset, int length)
Appends the specified contents of the supplied byte[] to the list.
boolean addAll(byte[] src)
Appends the full 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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ByteArrayList ()

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

public ByteArrayList (int defaultSize)

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

Parameters
defaultSize The initial capacity of the list, in bytes

public ByteArrayList (int defaultSize, float growthFactor)

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

Parameters
defaultSize The initial capacity of the list, in bytes
growthFactor The factor by which the capacity is multiplied when the list needs to auto-resize. Must be >= 1.1f.

Public Methods

public boolean add (byte b)

Appends the specified element to the end of this list

Parameters
b The byte to append to the list
Returns
  • true

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

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

Parameters
src The byte[] to append contents from
srcOffset The index of first element of src to append
length The quantity of bytes to append to the list
Returns
  • true

public boolean addAll (byte[] src)

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

Parameters
src The byte[] to append contents from
Returns
  • true

public boolean addall (ByteArrayList src)

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

Parameters
src The ByteArrayList to append contents from
Returns
  • true

public void clear ()

Removes all of the elements from this list.

public 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 The minimum capacity to ensure storage for, in bytes

public boolean equals (Object other)

public byte get (int idx)

Returns the element at the specified position in this list

Parameters
idx The index to return

public byte[] getContents ()

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

Returns
  • A byte[] copy of the list contents

public int hashCode ()

public boolean isEmpty ()

Returns true if this list contains no bytes

public byte set (int idx, byte b)

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

Parameters
idx The index to replace
b The byte to replace at that index

public int size ()

Returns the number of bytes in this list

public void trimToSize ()

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