Package com.luna.common.io
Class FastByteBuffer
java.lang.Object
com.luna.common.io.FastByteBuffer
代码移植自blade
快速缓冲,将数据存放在缓冲集中,取代以往的单一数组
快速缓冲,将数据存放在缓冲集中,取代以往的单一数组
- Since:
- 1.0
- Author:
- biezhi, looly
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(byte element) 向快速缓冲加入一个字节append(byte[] array) 向快速缓冲加入数据append(byte[] array, int off, int len) 向快速缓冲加入数据append(FastByteBuffer buff) 将另一个快速缓冲加入到自身byte[]array(int index) 根据索引位返回缓冲集中的缓冲byteget(int index) 根据索引位返回一个字节intindex()当前缓冲位于缓冲区的索引位booleanisEmpty()intoffset()voidreset()intsize()byte[]toArray()返回快速缓冲中的数据byte[]toArray(int start, int len) 返回快速缓冲中的数据
-
Constructor Details
-
FastByteBuffer
public FastByteBuffer() -
FastByteBuffer
public FastByteBuffer(int size)
-
-
Method Details
-
append
向快速缓冲加入数据- Parameters:
array- 数据off- 偏移量len- 字节数- Returns:
- 快速缓冲自身 @see FastByteBuffer
-
append
向快速缓冲加入数据- Parameters:
array- 数据- Returns:
- 快速缓冲自身 @see FastByteBuffer
-
append
向快速缓冲加入一个字节- Parameters:
element- 一个字节的数据- Returns:
- 快速缓冲自身 @see FastByteBuffer
-
append
将另一个快速缓冲加入到自身- Parameters:
buff- 快速缓冲- Returns:
- 快速缓冲自身 @see FastByteBuffer
-
size
public int size() -
isEmpty
public boolean isEmpty() -
index
public int index()当前缓冲位于缓冲区的索引位- Returns:
currentBufferIndex
-
offset
public int offset() -
array
public byte[] array(int index) 根据索引位返回缓冲集中的缓冲- Parameters:
index- 索引位- Returns:
- 缓冲
-
reset
public void reset() -
toArray
public byte[] toArray()返回快速缓冲中的数据- Returns:
- 快速缓冲中的数据
-
toArray
public byte[] toArray(int start, int len) 返回快速缓冲中的数据- Parameters:
start- 逻辑起始位置len- 逻辑字节长- Returns:
- 快速缓冲中的数据
-
get
public byte get(int index) 根据索引位返回一个字节- Parameters:
index- 索引位- Returns:
- 一个字节
-