|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.array.ByteArray32
232-entry virtual byte array.
Details: A ByteArray32
is an array of 232 byte
s. Every element in the array is available for reading and writing.
Because very few computing environments are equipped to handle physically allocated arrays of this size, ByteArray32
uses an on-
ByteArray32
is ideal for applications that require large, sparsely-ByteArray32
is efficient because it never requires array resizing, array copying, or address hashing (unlike a growable Vector
- or Hashtable
-ByteArray32
also permits a sequential enumeration of occupied memory cells (unlike a Hashtable
, which does not produce sequential output).
Array indices for this "virtual byte array" are specified using unsigned int
s. Byte elements can be accessed 1 byte or 4 bytes at a time. When 4 bytes are accessed simultaneously, the values are combined into a single int
structure. Indices used to access 4 bytes at a time are automatically aligned (ANDed with 0xfffffffc
).
Constructor Summary | |
ByteArray32(byte default_byte)
Initializes with default value. |
Method Summary | |
int |
compact()
Reduces storage requirements. |
void |
fill(int index,
int amount,
byte value)
Fills array. |
byte |
get(int index)
Retrieves byte. |
void |
get(int index,
byte[] dest,
int dest_from,
int amount)
Retrieves bytes. |
int |
getIntBe(int index)
Retrieves 32-bit word. |
int |
getIntLe(int index)
Retrieves 32-bit word. |
long |
search(int index,
int amount,
byte value)
Searches for value. |
void |
set(int index,
byte value)
Sets byte. |
void |
set(int index,
byte[] src,
int src_from,
int amount)
Sets bytes. |
void |
setIntBe(int index,
int value)
Sets 32-bit word. |
void |
setIntLe(int index,
int value)
Sets 32-bit word. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ByteArray32(byte default_byte)
Details: This constructor initializes a new ByteArray32 with all bytes set to the given initial value (default_byte).
default_byte
- the initial valueMethod Detail |
public byte get(int index)
Details: get
returns the byte at the given address (index).
index
- (unsigned) the addresspublic void set(int index, byte value)
Details: set
sets the byte at the given address (index) to the given value (value).
index
- (unsigned) the addressvalue
- the valuepublic void get(int index, byte[] dest, int dest_from, int amount)
Details: get
retrieves the given range of bytes (index, amount) and writes them into the destination array (dest).
index
- (unsigned) the addressdest
- the destination arraydest_from
- index of first byte in destamount
- number of bytes to retrievepublic void set(int index, byte[] src, int src_from, int amount)
Details: set
writes the given sequence of bytes (src, src_from, amount) into this array, starting at the given address (index).
index
- the addresssrc
- the byte sequencesrc_from
- index of first byte in srcamount
- number of bytes to writepublic int getIntBe(int index)
Details: getIntBe
returns the 32-
index
- the addresspublic int getIntLe(int index)
Details: getIntBe
returns the 32-
index
- the addresspublic void setIntBe(int index, int value)
Details: setIntBe
sets the 32-
index
- the addressvalue
- the wordpublic void setIntLe(int index, int value)
Details: setIntLe
sets the 32-
index
- the addressvalue
- the wordpublic void fill(int index, int amount, byte value)
Details: fill
writes the given byte value (value) into the given span of bytes (index, amount). For fill amounts greater than 256, this method can potentially reduce the storage requirements for this virtual array, especially if the fill value is the same as the default value by which this array was constructed.
index
- the addressamount
- the number of bytes to fillvalue
- the value to writepublic long search(int index, int amount, byte value)
Details: search
scans the array for the given value (value), beginning at the given address (index) and searching through amount bytes. If the value is found, its address is returned. Otherwise, -1 is returned.
index
- the address of the first byteamount
- number of bytes to searchvalue
- the value to seach forpublic int compact()
Details: compact
scans this array and, if possible, reduces its physical memory requirements by unallocating physical storage for pages whose byte values are all the same. If all of the bytes in this array are the same value, that value is returned. Otherwise, -1 is returned.
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |