mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/stats/reg] Share Store methods
This commit is contained in:
@@ -171,46 +171,12 @@ void Store::setDefault() {
|
||||
setYAuto(true);
|
||||
}
|
||||
|
||||
bool Store::isEmpty() const {
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int Store::numberOfNonEmptySeries() const {
|
||||
// TODO Share with stats in FLoatPairStore
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i< k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
return nonEmptySeriesCount;
|
||||
}
|
||||
/* Series */
|
||||
|
||||
bool Store::seriesIsEmpty(int series) const {
|
||||
return numberOfPairsOfSeries(series) < 2;
|
||||
}
|
||||
|
||||
int Store::indexOfKthNonEmptySeries(int k) const {
|
||||
// TODO put in DoublePairStore (it is also in stats/store)
|
||||
assert(k >= 0 && k < numberOfNonEmptySeries());
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
if (nonEmptySeriesCount == k) {
|
||||
return i;
|
||||
}
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculations */
|
||||
|
||||
double Store::doubleCastedNumberOfPairsOfSeries(int series) const {
|
||||
|
||||
@@ -29,10 +29,7 @@ public:
|
||||
void setDefault() override;
|
||||
|
||||
// Series
|
||||
bool isEmpty() const;
|
||||
int numberOfNonEmptySeries() const;
|
||||
bool seriesIsEmpty(int series) const;
|
||||
int indexOfKthNonEmptySeries(int k) const;
|
||||
bool seriesIsEmpty(int series) const override;
|
||||
|
||||
// Calculation
|
||||
double doubleCastedNumberOfPairsOfSeries(int series) const;
|
||||
|
||||
@@ -63,6 +63,41 @@ void DoublePairStore::resetColumn(int series, int i) {
|
||||
}
|
||||
}
|
||||
|
||||
bool DoublePairStore::isEmpty() const {
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DoublePairStore::numberOfNonEmptySeries() const {
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i< k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
return nonEmptySeriesCount;
|
||||
}
|
||||
|
||||
|
||||
int DoublePairStore::indexOfKthNonEmptySeries(int k) const {
|
||||
assert(k >= 0 && k < numberOfNonEmptySeries());
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
if (nonEmptySeriesCount == k) {
|
||||
return i;
|
||||
}
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DoublePairStore::sumOfColumn(int series, int i) const {
|
||||
assert(series >= 0 && series < k_numberOfSeries);
|
||||
assert(i == 0 || i == 1);
|
||||
|
||||
@@ -19,23 +19,38 @@ public:
|
||||
{}
|
||||
// Delete the implicit copy constructor: the object is heavy
|
||||
DoublePairStore(const DoublePairStore&) = delete;
|
||||
|
||||
// Get and set data
|
||||
double get(int series, int i, int j) const {
|
||||
assert(j < m_numberOfPairs[series]);
|
||||
return m_data[series][i][j];
|
||||
}
|
||||
virtual void set(double f, int series, int i, int j);
|
||||
|
||||
// Counts
|
||||
int numberOfPairs() const;
|
||||
int numberOfPairsOfSeries(int series) const {
|
||||
assert(series >= 0 && series < k_numberOfSeries);
|
||||
return m_numberOfPairs[series];
|
||||
}
|
||||
|
||||
// Delete and reset
|
||||
virtual void deletePairOfSeriesAtIndex(int series, int j);
|
||||
virtual void deleteAllPairsOfSeries(int series);
|
||||
void deleteAllPairs();
|
||||
void resetColumn(int series, int i);
|
||||
|
||||
// Series
|
||||
virtual bool isEmpty() const;
|
||||
virtual bool seriesIsEmpty(int series) const = 0;
|
||||
virtual int numberOfNonEmptySeries() const;
|
||||
int indexOfKthNonEmptySeries(int k) const;
|
||||
|
||||
// Calculations
|
||||
double sumOfColumn(int series, int i) const;
|
||||
uint32_t storeChecksum() const;
|
||||
|
||||
// Colors
|
||||
static KDColor colorOfSeriesAtIndex(int i) {
|
||||
assert(i >= 0 && i < k_numberOfSeries);
|
||||
return Palette::DataColor[i];
|
||||
|
||||
@@ -81,35 +81,15 @@ bool Store::scrollToSelectedBarIndex(int series, int index) {
|
||||
}
|
||||
|
||||
bool Store::isEmpty() const {
|
||||
for (int i = 0; i < k_numberOfSeries; i ++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int Store::numberOfNonEmptySeries() const {
|
||||
return m_numberOfNonEmptySeries;
|
||||
return numberOfNonEmptySeries() == 0;
|
||||
}
|
||||
|
||||
bool Store::seriesIsEmpty(int i) const {
|
||||
return m_seriesEmpty[i];
|
||||
}
|
||||
|
||||
int Store::indexOfKthNonEmptySeries(int k) const {
|
||||
assert(k >= 0 && k < numberOfNonEmptySeries());
|
||||
int nonEmptySeriesCount = 0;
|
||||
for (int i = 0; i < k_numberOfSeries; i++) {
|
||||
if (!seriesIsEmpty(i)) {
|
||||
if (nonEmptySeriesCount == k) {
|
||||
return i;
|
||||
}
|
||||
nonEmptySeriesCount++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return 0;
|
||||
int Store::numberOfNonEmptySeries() const {
|
||||
return m_numberOfNonEmptySeries;
|
||||
}
|
||||
|
||||
/* Calculation */
|
||||
|
||||
@@ -22,10 +22,9 @@ public:
|
||||
double numberOfBars(int series) const;
|
||||
// return true if the window has scrolled
|
||||
bool scrollToSelectedBarIndex(int series, int index);
|
||||
bool isEmpty() const;
|
||||
int numberOfNonEmptySeries() const;
|
||||
bool seriesIsEmpty(int i) const;
|
||||
int indexOfKthNonEmptySeries(int k) const;
|
||||
bool isEmpty() const override;
|
||||
bool seriesIsEmpty(int i) const override;
|
||||
int numberOfNonEmptySeries() const override;
|
||||
|
||||
// Calculation
|
||||
double sumOfOccurrences(int series) const;
|
||||
|
||||
Reference in New Issue
Block a user