summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2018-08-23 16:51:02 -0300
committerSamuel Fadel <samuel@nihil.ws>2018-08-23 16:51:02 -0300
commit8378f1a885678569b593f94ddeabea9f734de64f (patch)
tree8c2f71a3a381f648484b29340c9719715bac7a61
parent9963dd0a9816f1ee58b84a2589cfcb9b4f574f68 (diff)
Use std::array instead of plain array.master
-rw-r--r--src/main.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 5972b4d..31c8a59 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,11 +1,11 @@
#include <cmath>
#include <algorithm>
+#include <array>
#include <iostream>
#include <iterator>
#include <vector>
-const char *TICKS[] = {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"};
-const size_t NUM_TICKS = 8;
+const std::array<const char *, 8> TICKS = {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"};
const double EPSILON = 1e-8;
template<typename InputIterator, typename OutputIterator>
@@ -18,7 +18,7 @@ void sparkify(InputIterator first, InputIterator last, OutputIterator &out) {
if (values_range < EPSILON) {
std::fill_n(out, last - first, TICKS[0]);
} else {
- auto coef = (NUM_TICKS - 1) / values_range;
+ auto coef = (TICKS.size() - 1) / values_range;
std::transform(first, last, out, [&](auto x) {
return TICKS[(size_t) round((x - min) * coef)];
});