Package org.apache.fop.hyphenation
Class ByteVector
- java.lang.Object
-
- org.apache.fop.hyphenation.ByteVector
-
- All Implemented Interfaces:
java.io.Serializable
public class ByteVector extends java.lang.Object implements java.io.Serializable
This class implements a simple byte vector with access to the underlying array.
This work was authored by Carlos Villegas (cav@uniscope.co.jp).
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
array
The encapsulated arrayprivate int
blockSize
private static int
DEFAULT_BLOCK_SIZE
Capacity increment sizeprivate int
n
Points to next free itemprivate static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ByteVector()
Construct byte vector instance with default block size.ByteVector(byte[] a)
Construct byte vector instance.ByteVector(byte[] a, int capacity)
Construct byte vector instance.ByteVector(int capacity)
Construct byte vector instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
alloc(int size)
This is to implement memory allocation in the array.int
capacity()
Obtain capacity of array.byte
get(int index)
Get byte at index.byte[]
getArray()
Obtain byte vector array.int
length()
Obtain number of items in array.void
put(int index, byte val)
Pet byte at index.void
trimToSize()
Trim byte vector to current length.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_BLOCK_SIZE
private static final int DEFAULT_BLOCK_SIZE
Capacity increment size- See Also:
- Constant Field Values
-
blockSize
private int blockSize
-
array
private byte[] array
The encapsulated array
-
n
private int n
Points to next free item
-
-
Constructor Detail
-
ByteVector
public ByteVector()
Construct byte vector instance with default block size.
-
ByteVector
public ByteVector(int capacity)
Construct byte vector instance.- Parameters:
capacity
- initial block size
-
ByteVector
public ByteVector(byte[] a)
Construct byte vector instance.- Parameters:
a
- byte array to use TODO should n should be initialized to a.length to be consistent with CharVector behavior? [GA]
-
ByteVector
public ByteVector(byte[] a, int capacity)
Construct byte vector instance.- Parameters:
a
- byte array to usecapacity
- initial block size TODO should n should be initialized to a.length to be consistent with CharVector behavior? [GA]
-
-
Method Detail
-
getArray
public byte[] getArray()
Obtain byte vector array.- Returns:
- byte array
-
length
public int length()
Obtain number of items in array.- Returns:
- number of items
-
capacity
public int capacity()
Obtain capacity of array.- Returns:
- current capacity of array
-
put
public void put(int index, byte val)
Pet byte at index.- Parameters:
index
- the indexval
- a byte
-
get
public byte get(int index)
Get byte at index.- Parameters:
index
- the index- Returns:
- a byte
-
alloc
public int alloc(int size)
This is to implement memory allocation in the array. Like malloc().- Parameters:
size
- to allocate- Returns:
- previous length
-
trimToSize
public void trimToSize()
Trim byte vector to current length.
-
-