|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.omegahat.Environment.ObjectDataStructures.vector
Abstract class used to represent an S/R-like vector-based container
for different elements, much like a Java array but with extensions.
This provides different facilities such as operator overloading (+,-,*,/, [, [[), apply supporting functions and methods, etc.
This version (as opposed to
vector
vector) contains most of the functionality inherited
by the different typed classes -
integer, numeric, etc.
| Field Summary | |
protected java.util.Vector |
_data
Array of the elements managed by this vector. |
protected static long |
NA_PATTERN
|
static java.lang.Object |
NullObject
|
| Fields inherited from interface org.omegahat.Environment.DataStructures.MathOperable |
DIVIDE, MINUS, MULTIPLY, PLUS |
| Constructor Summary | |
protected |
vector()
Default method for use in derived classes. |
|
vector(int n)
Specify just the length and initialize the array for storing the elements. |
|
vector(long n)
Specify the length. |
|
vector(long n,
boolean initialize)
|
|
vector(vector src,
boolean copy)
Constructor to duplicate an existing vector, either initially linking the data or copying the container for the elments - semi deep copy. |
| Method Summary | |
void |
add(double value,
int which)
|
void |
add(java.lang.Object value,
int which)
|
int |
addElement(java.lang.Object el)
|
java.lang.Object |
addValue(java.lang.Object rhs,
boolean inPlace)
Method for operator + overloading. |
vector |
apply(Function func)
|
vector |
apply(java.lang.String method)
Invoke the method specified by name for each of the elements in the |
java.lang.Object[] |
asArray()
|
protected java.lang.Object |
assignElement(int which,
java.lang.Object element)
Assumes that the _data array has been expanded suitably. |
java.lang.Object |
assignSubset(java.lang.Object index,
java.lang.Object value)
|
protected abstract java.lang.Object |
convertElement(java.lang.Object element)
|
vector |
copy(boolean all)
A generic method that copies the contents of the a vector or sub-class using reflectance. |
java.lang.Object |
createElement(double orig)
Create a new element to be added to this vector using the default class of the elements. |
java.lang.Object |
createElement(double orig,
java.lang.Object el)
Create a new element for the vector using the first argument as the value and the second argument as a template which should be mimiced, if possible. |
VariableInt |
createVariable()
|
java.util.Vector |
data()
|
java.util.Vector |
data(int i)
|
java.util.Vector |
data(int i,
java.lang.Object el)
|
java.util.Vector |
data(java.lang.Object x)
|
java.util.Vector |
data(java.lang.Object[] x)
|
java.lang.Object |
divide(java.lang.Number other)
|
java.lang.Object |
divide(vector other)
|
java.lang.Object |
divideValue(java.lang.Object rhs,
boolean inPlace)
Method for operator / overloading. |
java.lang.Object |
element(int i)
|
protected java.lang.Object |
elementMathOp(java.lang.Object el,
double v,
int op)
Internal method for performing the low-level math operation on the element el and right hand side v
given the operation type op |
java.lang.String |
elementToString(java.lang.Object el)
|
java.lang.Object |
exp(vector other)
|
java.lang.reflect.Method |
findMethod(java.lang.String name,
java.lang.Object obj)
|
DataFrameInt |
getDataFrame()
|
java.lang.String |
getName()
Method for Variable interface. |
logical |
isNA()
|
logical |
isNA(int which)
|
int |
length()
|
int |
length(int n)
Set the length of the collection, either initializing the array or resetting the length and copying the existing elements appropriately. |
int |
length(int n,
boolean initialize)
|
vector |
mathOperation(double v,
int op)
Iterate over the elements of this vector, performing the mathematical operation identified by op given the right hand side of the operation
as v |
java.lang.Object |
mathOperation(java.lang.Object rhs,
boolean inPlace,
int op)
General work-horse method for doing mathematical operations. |
java.lang.Object |
mathOperation(vector v,
int op)
General method for perform a mathematical operation with this object as the left hand side and the first argument v as the right hand side. |
java.util.Hashtable |
metaData()
Intended to be a Property table
for storing additional attributes and information about
a variable, including entries such as units, nicknames, source, etc. |
java.lang.Object |
minus(java.lang.Number other)
|
java.lang.Object |
minus(vector other)
|
java.lang.Object |
multiply(java.lang.Number other)
|
java.lang.Object |
multiply(vector other)
|
java.lang.Object |
multiplyValue(java.lang.Object rhs,
boolean inPlace)
Method for operator * overloading. |
long |
numObservations()
Return the length or number of records in this VariableInt. |
java.lang.Object |
plus(java.lang.Number other)
|
java.lang.Object |
plus(vector other)
|
int |
read(java.io.InputStream stream)
|
int |
read(java.io.Reader stream)
|
java.lang.String |
separator()
|
DataFrameInt |
setDataFrame(DataFrameInt fr)
|
java.lang.String |
setName(java.lang.String nm)
|
java.lang.Object |
subset(java.lang.Object index,
boolean keepStructure)
General method to compute the subset, usually called from the interactive language via expressions of the form x[[1]], x[y,2] |
java.lang.Object |
subtractValue(java.lang.Object rhs,
boolean inPlace)
Method for operator - overloading. |
abstract java.lang.Class |
targetClass()
The default class of each element in the list. |
java.lang.String |
toString()
|
java.lang.Object |
value(long which)
Return the whichth observation. |
VariableInt |
values(int[] indices)
Get a Variable consisting of the specified elements. |
VariableInt |
values(SelectorInt selector)
Get a Variable consisting of the specified elements from a
selector object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static final long NA_PATTERN
public static final java.lang.Object NullObject
protected java.util.Vector _data
| Constructor Detail |
protected vector()
public vector(int n)
public vector(long n)
vector(int)
public vector(long n,
boolean initialize)
public vector(vector src,
boolean copy)
| Method Detail |
public java.util.Hashtable metaData()
VariableIntProperty table
for storing additional attributes and information about
a variable, including entries such as units, nicknames, source, etc.metaData in interface VariableIntpublic java.util.Vector data(java.lang.Object[] x)
public java.util.Vector data(java.lang.Object x)
public java.util.Vector data()
public java.util.Vector data(int i)
public java.lang.Object element(int i)
public int length()
public java.util.Vector data(int i,
java.lang.Object el)
public logical isNA(int which)
public logical isNA()
public java.lang.Object[] asArray()
public java.lang.Object plus(vector other)
public java.lang.Object plus(java.lang.Number other)
public java.lang.Object minus(vector other)
public java.lang.Object minus(java.lang.Number other)
public java.lang.Object exp(vector other)
public java.lang.Object multiply(vector other)
public java.lang.Object multiply(java.lang.Number other)
public java.lang.Object divide(vector other)
public java.lang.Object divide(java.lang.Number other)
protected java.lang.Object assignElement(int which,
java.lang.Object element)
protected abstract java.lang.Object convertElement(java.lang.Object element)
public abstract java.lang.Class targetClass()
public int length(int n)
public int length(int n,
boolean initialize)
public vector apply(java.lang.String method)
throws java.lang.Throwable
Different variants are possible using a Database object as an argument or to attach a "non-constructable" (i.e new objects are not created in this) as the first element in the evaluators search path.
public java.lang.reflect.Method findMethod(java.lang.String name,
java.lang.Object obj)
public vector apply(Function func)
throws java.lang.Throwable
public vector copy(boolean all)
throws java.lang.Throwable
all indicates whether
we want a shallow copy or deep copy of the array.
This should be overridden in the different classes
for efficiency reasons.
public java.lang.Object subset(java.lang.Object index,
boolean keepStructure)
x[[1]], x[y,2]subset in interface Subsettablepublic VariableInt values(int[] indices)
VariableIntVariable consisting of the specified elements.values in interface VariableInt
public java.lang.Object assignSubset(java.lang.Object index,
java.lang.Object value)
assignSubset in interface AssignableSubsetpublic java.lang.String getName()
getName in interface VariableIntpublic java.lang.String setName(java.lang.String nm)
setName in interface VariableIntpublic DataFrameInt getDataFrame()
public DataFrameInt setDataFrame(DataFrameInt fr)
public java.lang.Object value(long which)
VariableIntvalue in interface VariableIntpublic long numObservations()
VariableIntVariableInt.numObservations in interface VariableIntpublic VariableInt values(SelectorInt selector)
VariableIntVariable consisting of the specified elements from a
selector object.values in interface VariableIntpublic VariableInt createVariable()
public java.lang.Object addValue(java.lang.Object rhs,
boolean inPlace)
addValue in interface Addable
public java.lang.Object subtractValue(java.lang.Object rhs,
boolean inPlace)
subtractValue in interface Subtractable
public java.lang.Object multiplyValue(java.lang.Object rhs,
boolean inPlace)
multiplyValue in interface Multiplicable
public java.lang.Object divideValue(java.lang.Object rhs,
boolean inPlace)
divideValue in interface Divisable
public java.lang.Object mathOperation(java.lang.Object rhs,
boolean inPlace,
int op)
rhs.rhs - right hand side of the binary operation that can be
a number or another vector. Other types are currently rejected.inPlace - whether to copy the vector and do the operations
on the copy or to change the values in this instance.op - value indicating which mathematical operation
to perform.
See
MathOperable
public vector mathOperation(double v,
int op)
op given the right hand side of the operation
as v
protected java.lang.Object elementMathOp(java.lang.Object el,
double v,
int op)
el and right hand side v
given the operation type opel - element of this vector which is the first element
of the binary mathematical operation.v - second term in binary mathematical operationop - type of mathematical operation to perform.public java.lang.Object createElement(double orig)
public java.lang.Object createElement(double orig,
java.lang.Object el)
character.
public java.lang.Object mathOperation(vector v,
int op)
v as the right hand side.
The particular operation is specified as a symbolic constant
op.
See MathOperable.public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String elementToString(java.lang.Object el)
public java.lang.String separator()
public int addElement(java.lang.Object el)
public void add(double value,
int which)
add in interface VariableInt
public void add(java.lang.Object value,
int which)
add in interface VariableIntpublic int read(java.io.InputStream stream)
public int read(java.io.Reader stream)
read in interface VariableInt
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||