ru.sscc.util.data
Class RealPointer

java.lang.Object
  |
  +--ru.sscc.util.data.RealPointer
Direct Known Subclasses:
ChainPointer, DoubleIRefPointer, DoubleIVecPointer, DoublePointer, DoubleSRefPointer, DoubleSVecPointer, FloatIRefPointer, FloatIVecPointer, FloatPointer, FloatSRefPointer, FloatSVecPointer, RealPointers, SimplePointer

public abstract class RealPointer
extends java.lang.Object
implements java.lang.Cloneable

An abstract implementation of the sequential access to the vector distributed within a real data container by the regular manner (for example, with the fixed distance between neighbouring entries).


Field Summary
protected  int index
          An index of the current vector entry in the container.
protected  int step
          An increment step - the distance between neighbouring vector entries.
 
Constructor Summary
protected RealPointer(int index, int step)
          Constructs the pointer to the vector having the required starting index and increment step.
 
Method Summary
abstract  double add(double value)
          Adds a value to the entry at the current pointer position.
static RealPointer by(java.lang.Object obj)
          Static service method which creates RealPointer upon an object convertable to it (double[], float[], RealContainer, RealVector, or RealPointer instance).
 java.lang.Object clone()
          Clones the pointer.
abstract  double get()
          Gets an entry value at the current pointer position.
 RealPointer invert()
          Inverts the pointer's direction (changes step sign).
abstract  double mul(double value)
          Multiplies the entry at the current pointer position by a value.
 RealPointer next()
          Moves pointer to the next vector entry (the same as shift(1)).
 RealPointer previous()
          Moves pointer to the previous vector entry (the same as shift(-1)).
 RealPointer reset(int index, int step)
          Resets the pointer's position and increment to new values respective to the vector structure choosen when the pointer was constructed.
 void restore(long value)
          Restores the pointer's index and step using a value saved in save operation.
 long save()
          Packs the current pointer's index and step into long variable and returns it.
abstract  double set(double value)
          Sets an entry value at the current pointer position.
 RealPointer shift(int count)
          Moves pointer upto count vector entries.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

index

protected int index
An index of the current vector entry in the container.

step

protected int step
An increment step - the distance between neighbouring vector entries.
Constructor Detail

RealPointer

protected RealPointer(int index,
                      int step)
Constructs the pointer to the vector having the required starting index and increment step.
Parameters:
index - a starting index in the container
step - an increment step
Method Detail

get

public abstract double get()
Gets an entry value at the current pointer position.
Returns:
value of the current entry

set

public abstract double set(double value)
Sets an entry value at the current pointer position.
Parameters:
value - a value to set
Returns:
the set value

add

public abstract double add(double value)
Adds a value to the entry at the current pointer position.
Parameters:
value - a value to add
Returns:
the result of addition

mul

public abstract double mul(double value)
Multiplies the entry at the current pointer position by a value.
Parameters:
value - a value to add
Returns:
the result of multiplication

next

public final RealPointer next()
Moves pointer to the next vector entry (the same as shift(1)).
Returns:
the moved pointer

previous

public final RealPointer previous()
Moves pointer to the previous vector entry (the same as shift(-1)).
Returns:
the moved pointer

shift

public final RealPointer shift(int count)
Moves pointer upto count vector entries.
Parameters:
count - a shift value
Returns:
the moved pointer

invert

public final RealPointer invert()
Inverts the pointer's direction (changes step sign).

save

public long save()
Packs the current pointer's index and step into long variable and returns it.
Returns:
packed index and step

restore

public void restore(long value)
Restores the pointer's index and step using a value saved in save operation.
Parameters:
value - a value to restore

reset

public RealPointer reset(int index,
                         int step)
Resets the pointer's position and increment to new values respective to the vector structure choosen when the pointer was constructed. If the pointer was constructed with some base index and step, then the resetting of the pointer works by the following way: the current index in the container is calculated as baseIndex+baseStep*index and the current step is set as baseStep*step.
Parameters:
index - the new pointer position in the vector
step - the new increment step in the vector
Returns:
the resetted pointer

clone

public java.lang.Object clone()
Clones the pointer.
Overrides:
clone in class java.lang.Object
Returns:
clone of this pointer

by

public static RealPointer by(java.lang.Object obj)
Static service method which creates RealPointer upon an object convertable to it (double[], float[], RealContainer, RealVector, or RealPointer instance). In the last case a clone of the pointer is created.