|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.magnos.data.AbstractData
org.magnos.data.DataArray<T>
T
- The type of element stored in the array.public class DataArray<T extends Data>
An array of data elements which are the same type and size. An array can be either lazy or not. A lazy array does not allocate an array to store the data elements, but instead creates a new element for each get and doesn't cache the element in the set. An array that is not lazy will have an internal cache of items
Constructor Summary | |
---|---|
DataArray(T root,
int count,
boolean lazy)
Instantiates a new DataArray. |
Method Summary | ||
---|---|---|
Data |
copy()
Creates a clone of this data. |
|
static
|
create(java.lang.Class<E> type,
int count,
boolean lazy)
Creates a new DataArray given an element type to which elements in the created array should be instantiated form. |
|
static
|
create(E root,
int count,
boolean lazy)
Creates a new DataArray given a root element to which elements in the created array should be copied from. |
|
T |
get(int index)
Gets the data at the given index. |
|
int |
getLength()
Returns the number of elements in the array. |
|
protected void |
onRead(int location,
Store store)
Reads this data from the given store at the given location. |
|
protected void |
onWrite(int location,
Store store)
Writes this data to the given store at the given location. |
|
void |
set(int index,
T data)
Sets the data at the given index. |
|
T |
update(int index)
Updates the data element at the given index and returns it. |
Methods inherited from class org.magnos.data.AbstractData |
---|
getActualLocation, getLocation, getParent, getSize, getStore, read, read, read, read, setLocation, setParent, setStore, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataArray(T root, int count, boolean lazy)
root
- The data to use to create other data objects of similar type and
having the same characteristics.count
- The number of data elements to store in the array.lazy
- Whether or not this array is lazy. A lazy array will read data
everytime a get is invoked, and will write data everytime a set
is invoked. A non-lazy array will only call write and read to each
data item when write or read is explicitly called on the array,
which also requires the data items to be stored in memory at all
times. To save space use a lazy array (true), for a slightly more
efficient array choose a non-lazy array (false).Method Detail |
---|
public T get(int index)
index
- The index of the data in the array.
public T update(int index)
index
- The index of the data in the array.
public void set(int index, T data)
index
- The index of the data in the array.data
- The data to set.public int getLength()
protected void onRead(int location, Store store)
onRead
in class AbstractData
location
- The offset in bytes from the beginning of the store to read from.store
- The store to read from.protected void onWrite(int location, Store store)
onWrite
in class AbstractData
location
- The offset in bytes from the beginning of the store to write to.store
- The store to write to.public Data copy()
public static <E extends Data> DataArray<E> create(E root, int count, boolean lazy)
E
- The type of element in the array.root
- The element to use for copying.count
- The number of data elements in the array.lazy
- Whether or not this array is lazy. A lazy array will read data
everytime a get is invoked, and will write data everytime a set
is invoked. A non-lazy array will only call write and read to each
data item when write or read is explicitly called on the array,
which also requires the data items to be stored in memory at all
times. To save space use a lazy array (true), for a slightly more
efficient array choose a non-lazy array (false).
public static <E extends Data> DataArray<E> create(java.lang.Class<E> type, int count, boolean lazy)
E
- The type of element in the array.type
- The class of the data element.count
- The number of data elements in the array.lazy
- Whether or not this array is lazy. A lazy array will read data
everytime a get is invoked, and will write data everytime a set
is invoked. A non-lazy array will only call write and read to each
data item when write or read is explicitly called on the array,
which also requires the data items to be stored in memory at all
times. To save space use a lazy array (true), for a slightly more
efficient array choose a non-lazy array (false).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |