|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgoodsjpi.Persistent
goodslib.AnyArray
goodslib.ArrayOfDouble
ArrayOfDouble
is just that, an array of doubles. It is fully
persistent, as it it's derived from Persistent. All reads cause a fetch of the
data, all writes mark it dirty and to be saved.
Field Summary | |
protected double[] |
array
array holds the doubles in an [] |
Fields inherited from class goodslib.AnyArray |
used |
Fields inherited from class goodsjpi.Persistent |
defaultMetaobject, metaobject |
Constructor Summary | |
ArrayOfDouble(double[] src)
Creates a new ArrayOfDouble instance, as a copy of the given
double[] |
|
ArrayOfDouble(int size)
Creates a new ArrayOfDouble instance. |
|
ArrayOfDouble(int size,
int allocatedSize)
Creates a new ArrayOfDouble instance. |
Method Summary | |
void |
append(double[] tail)
append add the given values to the end of the array |
void |
changeSize(int newSize)
Resize the amount of space taken by the array. |
void |
copy(int dstIndex,
double[] src,
int srcIndex,
int count)
copy into this array from a destination, a given amount of values.
|
double |
getAt(int index)
Get a double at the specified index |
int |
indexOf(double val)
indexOf returns the first occurrence of val |
void |
insert(int index,
int count,
double value)
insert a "count" amount of values at a given index. |
int |
lastIndexOf(double val)
Find the lastIndexOf a given value |
double |
pop()
Use the array as a stack and pop a value. |
void |
push(double value)
Use the array as a stack with the push method. |
void |
putAt(int index,
double value)
Put a double value at a given index |
void |
remove(int index,
int count)
remove a number of values. |
double[] |
toArray()
toArray converts the internal representation to a double[] , of
correct size. |
double |
top()
Check the top boolean with the top method. |
Methods inherited from class goodslib.AnyArray |
length |
Methods inherited from class goodsjpi.Persistent |
attachToStorage, clone, clusterWith, finalize, getDatabase, getOid, getStorageId, hashCode, onLoad |
Methods inherited from class java.lang.Object |
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected double[] array
array
holds the doubles in an []
Constructor Detail |
public ArrayOfDouble(int size)
ArrayOfDouble
instance.
size
- is the initial size, (length)public ArrayOfDouble(int size, int allocatedSize)
ArrayOfDouble
instance. (Full of false)
size
- , or length of the arrayallocatedSize
- is the size it can grow to without resizingpublic ArrayOfDouble(double[] src)
ArrayOfDouble
instance, as a copy of the given
double[]
src
- a double[]
that will be copiedMethod Detail |
public void putAt(int index, double value)
index
- an int
value, where the value should be setvalue
- the double
value to be setpublic double getAt(int index)
index
- of the double you want
double
value, at index "index"public void changeSize(int newSize)
newSize
- an int
denoting the new size.public void insert(int index, int count, double value)
insert
a "count" amount of values at a given index. Throws an
IndexOutOfBoundsException for too small (<0) or too big (>length) count or index.
index
- , where to start inserting value(s)count
- , how many values to insertvalue
- a double
value to insertpublic void remove(int index, int count)
remove
a number of values. The array shrinks in it's length, but no
resizing is done. Get an IndexOutOfBoundsException for inappropriate index or
count values.
index
- , where to start removingcount
- , how many values to removepublic void push(double value)
push
method.
value
- , a double
to push to the stackpublic double pop()
pop
a value. (Value is removed)
IndexOutOfBoundsExceptions comes when array has hit 0 length.
double
valuepublic double top()
top
method. This returns what
pop
returns, just it doesn't remove the value. In other stack
implementations it may be called peek()
double
valuepublic void append(double[] tail)
append
add the given values to the end of the array
tail
- a double[]
that will be appendedpublic double[] toArray()
toArray
converts the internal representation to a double[] , of
correct size. Ie: the .length of the return == this.size()
double[]
valuepublic void copy(int dstIndex, double[] src, int srcIndex, int count)
copy
into this array from a destination, a given amount of values.
Get a IndexOutOfBounds if the src or count don't fit
dstIndex
- , the index (of this array) where to copy tosrc
- a double[]
, where to copy fromsrcIndex
- an int
, where to start copying fromcount
- an int
, how many values to copypublic int indexOf(double val)
indexOf
returns the first occurrence of val
val
- a double
to be looked for
int
, where the value was found, or -1public int lastIndexOf(double val)
lastIndexOf
a given value
val
- a double
value to be found (from the back)
int
, where the value was found, or -1
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |