| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||
java.lang.Object | +--ncsa.horizon.util.IntLikeDblArray
This is useful for holding array values that are usually accessed as integer values, but can have fractional values. Methods for getting and setting the values are made final for efficient and fast access. The storage is optimized for integer access by storing the integer part of the value separately from the fractional part. How the floating point value is converted to an integer can be set via the setConversionMode(), allowing 3 possible modes: ROUND, CEILING, and FLOOR. The changing the mode changes how the values are stored, optimizing for the requested conversion. The ROUND mode simply rounds the value to the nearest integer in the usual way (equivalent to Math.round()). FLOOR will convert the value to the greatest integer that is less than or equal to the value. CEILING will convert to the smallest integer that is greater than or equal to the value. (In all cases, "smaller" means more negative, and "larger" more positive.)
| Field Summary | |
| static byte | CEILING
the "ceiling-ing" conversion mode. |
| static byte | FLOOR
the "flooring" conversion mode. |
| static int | MAX_VALUE
the largest value an array element can hold. |
| static int | MIN_VALUE
the smallest value an array element can hold. |
| static byte | ROUND
the rounding conversion mode. |
| Constructor Summary | |
| IntLikeDblArray(int n,
byte mode)
create an array of a requested length and conversion mode. |
|
| IntLikeDblArray(int n)
create an array of a requested length. |
|
| IntLikeDblArray(int n,
byte mode,
int val)
create an array of a requested length and conversion mode. |
|
| IntLikeDblArray(int n,
byte mode,
double val)
create an array of a requested length and conversion mode. |
|
| Method Summary | |
| void | addDbl(int idx,
double val)
add a floating point amount to the value at a given index |
| void | addDbl(int idx,
int i,
float f)
add a floating point amount to the value at a given index. |
| void | addInt(int idx,
int val)
add an integer amount to the value at a given index |
| void | add(int idx,
IntLikeDblArray val)
add the value at a given index in another IntLikeDblArray to the corresponding value in this one. |
| void | clearZeroFrac()
eliminate fractional components if they are all equal to zero. |
| java.lang.Object | clone()
|
| java.io.DataOutput | dataOut(java.io.DataOutput dout)
write out our data to the data output. |
| boolean | equals(IntLikeDblArray that)
|
| byte[] | getConversionMode()
return the current conversion mode for each array element |
| byte | getConversionMode(int idx)
return the current conversion mode for a given element |
| double[] | getDbl()
return the values as an array of doubles |
| double | getDbl(int i)
return the value at a given index. |
| int[] | getInt()
return the values as an array of integers |
| int | getInt(int i)
return the value at a given index. |
| int[] | getIntRef()
return the values via a reference to an array of integers. |
| int | getLength()
return the length of the array (same as length()). |
| boolean | isFractional(int idx)
return true if the value at a given index has a fractional component |
| int | length()
return the length of the array (same as getLength()). |
| void | setConversionMode(int idx,
byte cmode)
set the current conversion mode for a given array element |
| void | setConversionMode(byte cmode)
set the current conversion mode for all array element to the same mode |
| void | setConversionMode(byte[] cmode)
set the current conversion mode for all array element to the same mode |
| void | setDbl(double[] val)
set the values to those in a given array of doubles |
| void | setDbl(int idx,
double val)
set the value at a given index. |
| void | setDbl(int idx,
int whole,
float fract)
set a component the position to the value given by the double value given by the input integer and float. |
| void | setInt(int[] val)
set the values to those in a given array of integers |
| void | setInt(int idx,
int val)
set the value at a given index |
| Methods inherited from class java.lang.Object | |
| clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait | |
| Field Detail |
public static final int MAX_VALUE
public static final int MIN_VALUE
public static final byte ROUND
public static final byte FLOOR
public static final byte CEILING
| Constructor Detail |
public IntLikeDblArray(int n,
byte mode)
throws ValueOutOfBoundsException
public IntLikeDblArray(int n)
public IntLikeDblArray(int n,
byte mode,
int val)
throws ValueOutOfBoundsException
n
- the number of array elements
mode
- the conversion mode to use
val
- the value to assign to each element
public IntLikeDblArray(int n,
byte mode,
double val)
throws ValueOutOfBoundsException
n
- the number of array elements
mode
- the conversion mode to use
val
- the value to assign to each element| Method Detail |
public final int length()
public final int getLength()
public final byte[] getConversionMode()
public final byte getConversionMode(int idx)
public final void setConversionMode(int idx,
byte cmode)
throws ValueOutOfBoundsException
public final void setConversionMode(byte cmode)
throws ValueOutOfBoundsException
public final void setConversionMode(byte[] cmode)
throws ValueOutOfBoundsException
public final int[] getInt()
public final int[] getIntRef()
public final int getInt(int i)
public final void setInt(int[] val)
public final void setInt(int idx,
int val)
public final void addInt(int idx,
int val)
public final double[] getDbl()
public final double getDbl(int i)
public final void setDbl(double[] val)
throws ValueOutOfBoundsException
public final void setDbl(int idx,
double val)
throws ValueOutOfBoundsException
public final void addDbl(int idx,
double val)
public void add(int idx,
IntLikeDblArray val)
protected void addDbl(int idx,
int i,
float f)
whole
- the integer part of the value
fract
- the fractional part of the value
protected void setDbl(int idx,
int whole,
float fract)
whole
- the integer part of the value
fract
- the fractional part of the valuepublic final void clearZeroFrac()
public boolean isFractional(int idx)
public java.lang.Object clone()
public boolean equals(IntLikeDblArray that)
public java.io.DataOutput dataOut(java.io.DataOutput dout)
throws java.io.IOException
| Overview | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||