位元組數組列表
public class ByteArrayList
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.ByteArrayList |
表示輕量級位元組數組的類別。此類別的目標是避免使用 Java 類別的大量空間開銷。例如,請參閱:http://benjchristensen.com/2008/05/27/java-memory-usage-ints/
概括
公共構造函數 | |
---|---|
ByteArrayList () 建構一個空列表,初始容量為128位元組,增長因子為2.0 | |
ByteArrayList (int defaultSize) 建構一個具有指定初始容量且成長因子為 2.0 的空列表 | |
ByteArrayList (int defaultSize, float growthFactor) 使用指定的初始容量和成長因子建構一個空列表 |
公共方法 | |
---|---|
boolean | add (byte b) 將指定元素追加到此清單的末尾 |
boolean | addAll (byte[] src) 將提供的 |
boolean | addAll (byte[] src, int srcOffset, int length) 將提供的 |
boolean | addall ( ByteArrayList src) 將提供的 |
void | clear () 從此清單中刪除所有元素。 |
void | ensureCapacity (int minCapacity) 如有必要,請增加此 |
boolean | equals (Object other) |
byte | get (int idx) 傳回此清單中指定位置的元素 |
byte[] | getContents () 以 |
int | hashCode () |
boolean | isEmpty () 如果此列表不包含字節,則傳回 |
byte | set (int idx, byte b) 將此清單中指定位置的元素替換為指定元素 |
int | size () 傳回此列表中的位元組數 |
void | trimToSize () 將此 |
公共構造函數
位元組數組列表
public ByteArrayList ()
建構一個空列表,初始容量為128位元組,增長因子為2.0
位元組數組列表
public ByteArrayList (int defaultSize)
建構一個具有指定初始容量且成長因子為 2.0 的空列表
參數 | |
---|---|
defaultSize | int :列表的初始容量,以位元組為單位 |
位元組數組列表
public ByteArrayList (int defaultSize, float growthFactor)
使用指定的初始容量和成長因子建構一個空列表
參數 | |
---|---|
defaultSize | int :列表的初始容量,以位元組為單位 |
growthFactor | float :當清單需要自動調整大小時,容量乘以的因子。必須>= 1.1f 。 |
公共方法
添加
public boolean add (byte b)
將指定元素追加到此清單的末尾
參數 | |
---|---|
b | byte :要附加到清單的byte |
退貨 | |
---|---|
boolean | true |
全部添加
public boolean addAll (byte[] src)
將提供的byte[]
的完整內容附加到清單中。
參數 | |
---|---|
src | byte :要附加內容的byte[] |
退貨 | |
---|---|
boolean | true |
全部添加
public boolean addAll (byte[] src, int srcOffset, int length)
將提供的byte[]
的指定內容追加到清單中。
參數 | |
---|---|
src | byte :要附加內容的byte[] |
srcOffset | int : src 中要追加的第一個元素的索引 |
length | int :要附加到清單的位元組數 |
退貨 | |
---|---|
boolean | true |
全部添加
public boolean addall (ByteArrayList src)
將提供的ByteArrayList
的完整內容追加到清單中。
參數 | |
---|---|
src | ByteArrayList :要從中追加內容的ByteArrayList |
退貨 | |
---|---|
boolean | true |
清除
public void clear ()
從此清單中刪除所有元素。
確保容量
public void ensureCapacity (int minCapacity)
如有必要,請增加此ByteArrayList
實例的容量,以確保它至少可以容納最小容量參數指定的位元組數。
參數 | |
---|---|
minCapacity | int : 確保儲存的最小容量,以位元組為單位 |
等於
public boolean equals (Object other)
參數 | |
---|---|
other | Object |
退貨 | |
---|---|
boolean |
得到
public byte get (int idx)
傳回此清單中指定位置的元素
參數 | |
---|---|
idx | int :要傳回的索引 |
退貨 | |
---|---|
byte |
取得內容
public byte[] getContents ()
以byte[]
形式傳回此ByteArrayList
內容的副本。
退貨 | |
---|---|
byte[] | 列表內容的byte[] 副本 |
哈希碼
public int hashCode ()
退貨 | |
---|---|
int |
是空的
public boolean isEmpty ()
如果此列表不包含字節,則傳回true
退貨 | |
---|---|
boolean |
放
public byte set (int idx, byte b)
將此清單中指定位置的元素替換為指定元素
參數 | |
---|---|
idx | int :要替換的索引 |
b | byte :在該索引處要替換的byte |
退貨 | |
---|---|
byte |
尺寸
public int size ()
傳回此列表中的位元組數
退貨 | |
---|---|
int |
修剪到大小
public void trimToSize ()
將此ByteArrayList
實例的容量修剪為清單的目前大小。