Skip to content

Commit

Permalink
refactor(DataTomeMvAvg): 🎨 mean and count aliases now belongs to Data…
Browse files Browse the repository at this point in the history
…TomeMvAvg instead of DataTomeAnalysis

Mean and count aliases now belongs to DataTomeMvAvg instead of DataTomeAnalysis. Comments were fixed to reflect the changes. keywords.txt was updated.
  • Loading branch information
AlexandreHiroyuki committed May 21, 2024
1 parent d0902ce commit c2ba738
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![Top Language](https://img.shields.io/github/languages/top/AlexandreHiroyuki/DataTome)](https://github.com/AlexandreHiroyuki/DataTome)

<p align="center">
<img src="./docs/icon.png" width="128" height="128" />
<img src="https://raw.githubusercontent.com/AlexandreHiroyuki/DataTome/main/docs/icon.png" width="128" height="128" />
</p>

## Description
Expand Down
15 changes: 15 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,43 @@ DataTomeAnalysis KEYWORD1
push KEYWORD2
get KEYWORD2
get_by_brute KEYWORD2
mean KEYWORD2

front KEYWORD2
back KEYWORD2

atIndex KEYWORD2
size KEYWORD2
point_count KEYWORD2
count KEYWORD2

grow KEYWORD2
resize KEYWORD2
clear KEYWORD2

partial_create KEYWORD2
partial_get KEYWORD2
partial_mean KEYWORD2
partial_size KEYWORD2
partial_point_count KEYWORD2
partial_count KEYWORD2

#######################################
# Methods and Functions (KEYWORD2)
# DataTomeAnalysis
#######################################

min KEYWORD2
max KEYWORD2
median KEYWORD2
lowest_mode KEYWORD2
highest_mode KEYWORD2
std KEYWORD2
var KEYWORD2
partial_min KEYWORD2
partial_max KEYWORD2
partial_median KEYWORD2
partial_lowest_mode KEYWORD2
partial_highest_mode KEYWORD2
partial_var KEYWORD2
partial_std KEYWORD2
4 changes: 3 additions & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
],
"export": {
"exclude": [
".github"
".github",
".gitignore",
".vscode"
]
},
"srcDir": "src"
Expand Down
18 changes: 0 additions & 18 deletions src/DataTomeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ class DataTomeAnalysis : public DataTomeMvAvg<TypeOfArray, TypeOfSum> {
public:
DataTomeAnalysis(size_t size) : DataTomeMvAvg<TypeOfArray, TypeOfSum>(size) {}

/** Aliases **/

TypeOfArray mean() { return this->get(); }
size_t count() { return this->point_count(); }

/** Proper Methods **/

TypeOfArray min() {
TypeOfArray min = (*this)[0];
for (size_t i = 1; i < this->point_count(); i++) {
Expand Down Expand Up @@ -150,17 +143,6 @@ class DataTomeAnalysis : public DataTomeMvAvg<TypeOfArray, TypeOfSum> {

/** Partial Methods **/

/** Aliases **/

TypeOfArray partial_mean(size_t partial_id) {
return this->partial_get(partial_id);
}
size_t partial_count(size_t partial_id) {
return this->partial_size(partial_id);
}

/** Proper Methods **/

TypeOfArray partial_min(size_t partial_id) {
TypeOfArray min = (*this)[0];
for (size_t i = 1; i < this->partial_point_count(partial_id); i++) {
Expand Down
16 changes: 16 additions & 0 deletions src/DataTomeMvAvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class DataTomeMvAvg {
// @alias get_by_brute
return get_by_brute(n_points);
}
TypeOfArray mean() {
// @alias get
return get();
}

TypeOfArray get_by_brute(size_t n_points) {
if (n_points > _average_counter) n_points = _average_counter;
Expand Down Expand Up @@ -127,6 +131,10 @@ class DataTomeMvAvg {
size_t size_of_memory() { return _array_size * sizeof(TypeOfArray); }

size_t point_count() { return _average_counter; }
size_t count() {
// @alias point_count
return point_count();
}

/** Modify array **/

Expand Down Expand Up @@ -197,6 +205,10 @@ class DataTomeMvAvg {
return _partial_sums[id] /
((_average_counter == 0) ? 1 : _average_counter);
}
TypeOfArray partial_mean(size_t id) {
// @alias partial_get
return partial_get(id);
}

size_t partial_size_of_array(size_t id) {
if (id > _partial_sums_counter) return 0;
Expand All @@ -214,6 +226,10 @@ class DataTomeMvAvg {
else
return _average_counter;
}
size_t partial_count(size_t id) {
// @alias partial_point_count
return partial_point_count(id);
}

size_t partials_memory() {
return sizeof(_partial_sums_counter) + sizeof(_partial_sums) +
Expand Down

0 comments on commit c2ba738

Please sign in to comment.