public abstract class CircularValueList
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CircularValueList.Statistics
Statistical information about a certain range of values.
|
Modifier and Type | Field and Description |
---|---|
int |
EOR
End Of Ring - largest valid index, not necessarily used! i.e.
|
int |
head
index of the entry most recently added
|
boolean |
maintainMinMax
Indicates whether the minimum and maximum values&indices are updated on
every add(), remove() or set() call
|
boolean |
maintainSum
Indicates whether the sum of all valid values is updated on every add(),
remove() or set() call
|
int |
maxIdx |
int |
minIdx |
int |
num
count of currently used indices
|
int |
sizeMax |
int |
tail
index of the oldest entry, when the ring is filled this will always be
head + 1
|
Constructor and Description |
---|
CircularValueList(int cacheSize)
Constructs a new CircularValueList with the given preallocated entries.
|
CircularValueList(int cacheSize,
boolean maintainMinMax)
Constructs a new CircularValueList with the given preallocated entries.
|
CircularValueList(int cacheSize,
boolean maintainMinMax,
boolean maintainSum)
Constructs a new CircularValueList with the given preallocated entries.
|
Modifier and Type | Method and Description |
---|---|
abstract int |
add(float newValue) |
abstract int |
add(long newValue) |
void |
clear() |
abstract void |
findMax() |
abstract void |
findMin() |
abstract void |
findMinMax() |
boolean |
isEmpty() |
int |
normIdx(int rIdx)
Normalizes the given negative or positive index.
|
int |
size() |
int |
tailDistance(int rIdx) |
public int sizeMax
head | +---+---+---+---+ | 0 | 1 | 2 | 3 | +---+---+---+---+ | | tail EOR num = 4 rIdx >= num rIdx = 5 = 5 - 4 = 1 rIdx = 4 = 4 - 4 = 0 rIdx < 0 rIdx = -2 = 4 - 2 = 2 rIdx = -4 = 4 - 4 = 0 rIdx < -num rIdx = -5 = 8 - 5 = 3 rIdx = -8 = 8 - 8 = 0
public int EOR
public int head
public int tail
public int num
public int minIdx
public int maxIdx
public boolean maintainMinMax
public boolean maintainSum
public CircularValueList(int cacheSize, boolean maintainMinMax, boolean maintainSum)
cacheSize
- Number of preallocated entries.maintainMinMax
- Whether to maintain the min and max values.public CircularValueList(int cacheSize, boolean maintainMinMax)
cacheSize
- Number of preallocated entries.maintainMinMax
- Whether to maintain the min and max values.public CircularValueList(int cacheSize)
cacheSize
- Number of preallocated entries.public void clear()
public int normIdx(int rIdx)
rIdx
- negative or positive index to normalizepublic int tailDistance(int rIdx)
rIdx
- public int size()
public boolean isEmpty()
public abstract int add(float newValue)
public abstract int add(long newValue)
public abstract void findMax()
public abstract void findMin()
public abstract void findMinMax()