summaryrefslogtreecommitdiffstats
path: root/src/big_array.hh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/big_array.hh58
1 files changed, 15 insertions, 43 deletions
diff --git a/src/big_array.hh b/src/big_array.hh
index 8401ead..d744dcb 100644
--- a/src/big_array.hh
+++ b/src/big_array.hh
@@ -35,17 +35,13 @@
#include <sys/mman.h>
#include <unistd.h>
+#include "base/lnav_log.hh"
#include "base/math_util.hh"
template<typename T>
struct big_array {
static const size_t DEFAULT_INCREMENT = 100 * 1000;
- big_array()
- : ba_ptr(nullptr), ba_size(0), ba_capacity(0){
-
- };
-
bool reserve(size_t size)
{
if (size < this->ba_capacity) {
@@ -71,17 +67,11 @@ struct big_array {
this->ba_ptr = (T*) result;
return true;
- };
+ }
- void clear()
- {
- this->ba_size = 0;
- };
+ void clear() { this->ba_size = 0; }
- size_t size() const
- {
- return this->ba_size;
- };
+ size_t size() const { return this->ba_size; }
void shrink_to(size_t new_size)
{
@@ -90,47 +80,29 @@ struct big_array {
this->ba_size = new_size;
}
- bool empty() const
- {
- return this->ba_size == 0;
- };
+ bool empty() const { return this->ba_size == 0; }
void push_back(const T& val)
{
this->ba_ptr[this->ba_size] = val;
this->ba_size += 1;
- };
+ }
- T& operator[](size_t index)
- {
- return this->ba_ptr[index];
- };
+ T& operator[](size_t index) { return this->ba_ptr[index]; }
- const T& operator[](size_t index) const
- {
- return this->ba_ptr[index];
- };
+ const T& operator[](size_t index) const { return this->ba_ptr[index]; }
- T& back()
- {
- return this->ba_ptr[this->ba_size - 1];
- }
+ T& back() { return this->ba_ptr[this->ba_size - 1]; }
- typedef T* iterator;
+ using iterator = T*;
- iterator begin()
- {
- return this->ba_ptr;
- };
+ iterator begin() { return this->ba_ptr; }
- iterator end()
- {
- return this->ba_ptr + this->ba_size;
- };
+ iterator end() { return this->ba_ptr + this->ba_size; }
- T* ba_ptr;
- size_t ba_size;
- size_t ba_capacity;
+ T* ba_ptr{nullptr};
+ size_t ba_size{0};
+ size_t ba_capacity{0};
};
#endif