From bd95f860355572d5ff40e7bc9055dd06d577e4c8 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Wed, 7 Dec 2022 21:35:10 +0100 Subject: [PATCH] Make classes uppercase --- src/lib/container/Array.h | 10 +++++----- src/lib/container/Span.h | 12 ++++++------ src/lib/container/Vector.h | 34 +++++++++++++++++----------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/lib/container/Array.h b/src/lib/container/Array.h index 6ed83e8..bdceae2 100644 --- a/src/lib/container/Array.h +++ b/src/lib/container/Array.h @@ -7,7 +7,7 @@ namespace Container { template - class array { + class Array { public: using iterator = ContinuousIterator; @@ -15,10 +15,10 @@ namespace Container { T buf[N]; public: - array() = default; // If i write default something like bse::array arr; is not initialized... + Array() = default; // If i write default something like bse::array arr; is not initialized... // Construct like this: bse::array {1, 2, 3, 4, 5}; - array(std::initializer_list list) { + Array(std::initializer_list list) { typename std::initializer_list::iterator it = list.begin(); for (unsigned int i = 0; i < N; ++i) { buf[i] = *it; @@ -37,7 +37,7 @@ namespace Container { T* data() { return &buf[0]; } const T* data() const { return &buf[0]; } - void swap(array& other) { + void swap(Array& other) { for (std::size_t i = 0; i < N; ++i) { std::swap(buf[i], other[i]); } @@ -46,7 +46,7 @@ namespace Container { // Array& other has to have size n: // arr1.swap_n<5>(arr2) => arr2 has size 5, arr1 has size >= 5 template - void swap_n(array& other) { + void swap_n(Array& other) { for (std::size_t i = 0; i < n; ++i) { std::swap(buf[i], other[i]); } diff --git a/src/lib/container/Span.h b/src/lib/container/Span.h index 6f3a56c..72dac7f 100644 --- a/src/lib/container/Span.h +++ b/src/lib/container/Span.h @@ -8,7 +8,7 @@ namespace Container { // 0 is unchecked template - class span { + class Span { public: using iterator = ContinuousIterator; @@ -17,11 +17,11 @@ namespace Container { const std::size_t sz = N; public: - span() = default; + Span() = default; - span(T* first) : ptr(first) {} + Span(T* first) : ptr(first) {} - span(T* first, T* last) : ptr(first), sz(last - first) {} + Span(T* first, T* last) : ptr(first), sz(last - first) {} iterator begin() { return iterator(ptr); } iterator begin() const { return iterator(ptr); } @@ -51,8 +51,8 @@ namespace Container { } // First is inclusive, last exclusive [first, last) - span& subspan(std::size_t first, std::size_t last = N) { - return span(ptr + first, ptr + last - 1); + Span& subspan(std::size_t first, std::size_t last = N) { + return Span(ptr + first, ptr + last - 1); } std::size_t size() const { diff --git a/src/lib/container/Vector.h b/src/lib/container/Vector.h index 76d4f8a..7be6bee 100644 --- a/src/lib/container/Vector.h +++ b/src/lib/container/Vector.h @@ -12,7 +12,7 @@ namespace Container { template - class vector { + class Vector { public: using iterator = ContinuousIterator; @@ -25,7 +25,7 @@ namespace Container { std::size_t buf_pos = 0; std::size_t buf_cap = 0; - void init(std::size_t cap = vector::default_cap) { + void init(std::size_t cap = Vector::default_cap) { if (buf != nullptr) { return; } @@ -33,7 +33,7 @@ namespace Container { buf_cap = cap; } - std::size_t get_rem_cap() const { + [[nodiscard]] std::size_t get_rem_cap() const { return buf_cap - size(); } @@ -100,7 +100,7 @@ namespace Container { } public: - explicit vector(bool lazy = false) { + explicit Vector(bool lazy = false) { if (!lazy) { // I added this as a work around, the scheduler can't initialize the queues right // away because when the scheduler is started the allocator is not ready. init(); @@ -108,7 +108,7 @@ namespace Container { }; // Initialize like this: bse::vector vec {1, 2, 3, 4, 5}; - vector(std::initializer_list list) : buf_cap(list.size()), buf(new T[buf_cap]) { + Vector(std::initializer_list list) : buf_cap(list.size()), buf(new T[buf_cap]) { typename std::initializer_list::iterator it = list.begin(); for (unsigned int i = 0; i < buf_pos; ++i) { buf[i] = *it; @@ -117,15 +117,15 @@ namespace Container { } - vector(const vector& copy) : buf_pos(copy.buf_pos), buf_cap(copy.buf_cap), buf(new T[buf_cap]) { + Vector(const Vector& copy) : buf_pos(copy.buf_pos), buf_cap(copy.buf_cap), buf(new T[buf_cap]) { for (unsigned int i = 0; i < buf_pos; ++i) { buf[i] = copy[i]; // Does a copy since copy is marked const reference } } - vector& operator=(const vector& copy) { + Vector& operator=(const Vector& copy) { if (this != ©) { - ~vector(); + ~Vector(); buf_cap = copy.buf_cap; buf_pos = copy.buf_pos; @@ -137,13 +137,13 @@ namespace Container { return *this; } - vector(vector&& move) noexcept : buf(move.buf), buf_pos(move.buf_pos), buf_cap(move.buf_cap) { + Vector(Vector&& move) noexcept : buf(move.buf), buf_pos(move.buf_pos), buf_cap(move.buf_cap) { move.buf_cap = 0; move.buf_pos = 0; move.buf = nullptr; } - vector& operator=(vector&& move) noexcept { + Vector& operator=(Vector&& move) noexcept { if (this != &move) { buf_cap = move.buf_cap; buf_pos = move.buf_pos; @@ -156,7 +156,7 @@ namespace Container { return *this; } - ~vector() { + ~Vector() { if (buf == nullptr) { return; } @@ -244,11 +244,11 @@ namespace Container { } // Misc - bool empty() const { + [[nodiscard]] bool empty() const { return !size(); } - std::size_t size() const { + [[nodiscard]] std::size_t size() const { return buf_pos; } @@ -259,7 +259,7 @@ namespace Container { } } - void reserve(std::size_t cap = vector::default_cap) { + void reserve(std::size_t cap = Vector::default_cap) { // The first reserve could allocate double if cap != default_cap if (buf == nullptr) { // Directly init with correct size @@ -275,7 +275,7 @@ namespace Container { switch_buf(cap); } - bool initialized() const { + [[nodiscard]] bool initialized() const { return buf != nullptr; } }; @@ -284,9 +284,9 @@ namespace Container { // NOTE: pred is no real predicate as one would need closures for this, but we don't have available // This means the result has to be passed separately and the function differs from the c++20 std::erase_if template - std::size_t erase_if(vector& vec, arg (*pred)(const T&), arg result) { + std::size_t erase_if(Vector& vec, arg (*pred)(const T&), arg result) { std::size_t erased_els = 0; - for (typename vector::Iterator it = vec.begin(); it != vec.end(); /*Do nothing*/) { + for (typename Vector::Iterator it = vec.begin(); it != vec.end(); /*Do nothing*/) { if (pred(*it) == result) { it = vec.erase(it); // erase returns the iterator to the next element ++erased_els;