From ea31d8f26cce5a33a65d60fd37f740346e398883 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Wed, 14 Feb 2024 15:21:59 -0500 Subject: [PATCH] add resize to scoped buffer to allow better usage in the GP assignment --- CMakeLists.txt | 0 CMakeSettings.json | 0 LICENSE | 0 README.md | 0 build_and_run_debug.sh | 0 commit.sh | 0 design.txt | 0 icon.png | Bin icon_large.png | Bin icon_small.png | Bin include/blt/config.h.in | 0 include/blt/fs/filesystem.h | 0 include/blt/fs/loader.h | 0 include/blt/fs/nbt.h | 0 include/blt/fs/nbt_block.h | 0 include/blt/math/averages.h | 0 include/blt/math/log_util.h | 0 include/blt/math/math.h | 0 include/blt/math/matrix.h | 0 include/blt/math/vectors.h | 0 include/blt/parse/argparse.h | 0 include/blt/parse/mustache.h | 0 include/blt/profiling/profiler.h | 0 include/blt/std/binary_tree.h | 0 include/blt/std/format.h | 0 include/blt/std/hashmap.h | 0 include/blt/std/logging.h | 0 include/blt/std/memory.h | 19 +++++++++++++++++-- include/blt/std/queue.h | 0 include/blt/std/random.h | 0 include/blt/std/string.h | 0 include/blt/std/system.h | 0 include/blt/std/time.h | 0 include/blt/std/uuid.h | 0 include/blt/window/window.h | 0 src/blt/fs/filesystem.cpp | 0 src/blt/fs/loader.cpp | 0 src/blt/fs/nbt.cpp | 0 src/blt/fs/nbt_block.cpp | 0 src/blt/parse/argparse.cpp | 0 src/blt/profiling/profiler.cpp | 0 src/blt/std/format.cpp | 0 src/blt/std/logging.cpp | 0 src/blt/std/string.cpp | 0 src/blt/std/system.cpp | 0 src/blt/window/window.cpp | 0 tests/clean.sh | 0 tests/src/binary_trees.h | 0 tests/src/hashmap_tests.h | 0 tests/src/logging.h | 0 tests/src/main.cpp | 0 tests/src/nbt_tests.cpp | 0 tests/src/nbt_tests.h | 0 tests/src/profiling_tests.h | 0 tests/src/queue_tests.h | 0 tests/test.sh | 0 56 files changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 CMakeSettings.json mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 build_and_run_debug.sh mode change 100644 => 100755 commit.sh mode change 100644 => 100755 design.txt mode change 100644 => 100755 icon.png mode change 100644 => 100755 icon_large.png mode change 100644 => 100755 icon_small.png mode change 100644 => 100755 include/blt/config.h.in mode change 100644 => 100755 include/blt/fs/filesystem.h mode change 100644 => 100755 include/blt/fs/loader.h mode change 100644 => 100755 include/blt/fs/nbt.h mode change 100644 => 100755 include/blt/fs/nbt_block.h mode change 100644 => 100755 include/blt/math/averages.h mode change 100644 => 100755 include/blt/math/log_util.h mode change 100644 => 100755 include/blt/math/math.h mode change 100644 => 100755 include/blt/math/matrix.h mode change 100644 => 100755 include/blt/math/vectors.h mode change 100644 => 100755 include/blt/parse/argparse.h mode change 100644 => 100755 include/blt/parse/mustache.h mode change 100644 => 100755 include/blt/profiling/profiler.h mode change 100644 => 100755 include/blt/std/binary_tree.h mode change 100644 => 100755 include/blt/std/format.h mode change 100644 => 100755 include/blt/std/hashmap.h mode change 100644 => 100755 include/blt/std/logging.h mode change 100644 => 100755 include/blt/std/memory.h mode change 100644 => 100755 include/blt/std/queue.h mode change 100644 => 100755 include/blt/std/random.h mode change 100644 => 100755 include/blt/std/string.h mode change 100644 => 100755 include/blt/std/system.h mode change 100644 => 100755 include/blt/std/time.h mode change 100644 => 100755 include/blt/std/uuid.h mode change 100644 => 100755 include/blt/window/window.h mode change 100644 => 100755 src/blt/fs/filesystem.cpp mode change 100644 => 100755 src/blt/fs/loader.cpp mode change 100644 => 100755 src/blt/fs/nbt.cpp mode change 100644 => 100755 src/blt/fs/nbt_block.cpp mode change 100644 => 100755 src/blt/parse/argparse.cpp mode change 100644 => 100755 src/blt/profiling/profiler.cpp mode change 100644 => 100755 src/blt/std/format.cpp mode change 100644 => 100755 src/blt/std/logging.cpp mode change 100644 => 100755 src/blt/std/string.cpp mode change 100644 => 100755 src/blt/std/system.cpp mode change 100644 => 100755 src/blt/window/window.cpp mode change 100644 => 100755 tests/clean.sh mode change 100644 => 100755 tests/src/binary_trees.h mode change 100644 => 100755 tests/src/hashmap_tests.h mode change 100644 => 100755 tests/src/logging.h mode change 100644 => 100755 tests/src/main.cpp mode change 100644 => 100755 tests/src/nbt_tests.cpp mode change 100644 => 100755 tests/src/nbt_tests.h mode change 100644 => 100755 tests/src/profiling_tests.h mode change 100644 => 100755 tests/src/queue_tests.h mode change 100644 => 100755 tests/test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/CMakeSettings.json b/CMakeSettings.json old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/build_and_run_debug.sh b/build_and_run_debug.sh old mode 100644 new mode 100755 diff --git a/commit.sh b/commit.sh old mode 100644 new mode 100755 diff --git a/design.txt b/design.txt old mode 100644 new mode 100755 diff --git a/icon.png b/icon.png old mode 100644 new mode 100755 diff --git a/icon_large.png b/icon_large.png old mode 100644 new mode 100755 diff --git a/icon_small.png b/icon_small.png old mode 100644 new mode 100755 diff --git a/include/blt/config.h.in b/include/blt/config.h.in old mode 100644 new mode 100755 diff --git a/include/blt/fs/filesystem.h b/include/blt/fs/filesystem.h old mode 100644 new mode 100755 diff --git a/include/blt/fs/loader.h b/include/blt/fs/loader.h old mode 100644 new mode 100755 diff --git a/include/blt/fs/nbt.h b/include/blt/fs/nbt.h old mode 100644 new mode 100755 diff --git a/include/blt/fs/nbt_block.h b/include/blt/fs/nbt_block.h old mode 100644 new mode 100755 diff --git a/include/blt/math/averages.h b/include/blt/math/averages.h old mode 100644 new mode 100755 diff --git a/include/blt/math/log_util.h b/include/blt/math/log_util.h old mode 100644 new mode 100755 diff --git a/include/blt/math/math.h b/include/blt/math/math.h old mode 100644 new mode 100755 diff --git a/include/blt/math/matrix.h b/include/blt/math/matrix.h old mode 100644 new mode 100755 diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h old mode 100644 new mode 100755 diff --git a/include/blt/parse/argparse.h b/include/blt/parse/argparse.h old mode 100644 new mode 100755 diff --git a/include/blt/parse/mustache.h b/include/blt/parse/mustache.h old mode 100644 new mode 100755 diff --git a/include/blt/profiling/profiler.h b/include/blt/profiling/profiler.h old mode 100644 new mode 100755 diff --git a/include/blt/std/binary_tree.h b/include/blt/std/binary_tree.h old mode 100644 new mode 100755 diff --git a/include/blt/std/format.h b/include/blt/std/format.h old mode 100644 new mode 100755 diff --git a/include/blt/std/hashmap.h b/include/blt/std/hashmap.h old mode 100644 new mode 100755 diff --git a/include/blt/std/logging.h b/include/blt/std/logging.h old mode 100644 new mode 100755 diff --git a/include/blt/std/memory.h b/include/blt/std/memory.h old mode 100644 new mode 100755 index 2d27854..a6436e9 --- a/include/blt/std/memory.h +++ b/include/blt/std/memory.h @@ -193,6 +193,21 @@ namespace blt return *this; } + /** + * Resize the internal buffer. Nothing will occur if the sizes are equal. + * This function WILL NOT COPY ANY DATA. It is meant for use when creating a scoped buffer without size. + */ + constexpr void resize(size_t size) + { + if (size == 0) + return; + if (size == size_) + return; + delete[] buffer_; + buffer_ = new T[size]; + size_ = size; + } + constexpr inline T& operator[](size_t index) { return buffer_[index]; @@ -232,7 +247,7 @@ namespace blt { return buffer_; } - + // inline auto begin() // { // return ptr_iterator{buffer_}; @@ -282,7 +297,7 @@ namespace blt { return reverse_iterator{cbegin()}; } - + ~scoped_buffer() { delete[] buffer_; diff --git a/include/blt/std/queue.h b/include/blt/std/queue.h old mode 100644 new mode 100755 diff --git a/include/blt/std/random.h b/include/blt/std/random.h old mode 100644 new mode 100755 diff --git a/include/blt/std/string.h b/include/blt/std/string.h old mode 100644 new mode 100755 diff --git a/include/blt/std/system.h b/include/blt/std/system.h old mode 100644 new mode 100755 diff --git a/include/blt/std/time.h b/include/blt/std/time.h old mode 100644 new mode 100755 diff --git a/include/blt/std/uuid.h b/include/blt/std/uuid.h old mode 100644 new mode 100755 diff --git a/include/blt/window/window.h b/include/blt/window/window.h old mode 100644 new mode 100755 diff --git a/src/blt/fs/filesystem.cpp b/src/blt/fs/filesystem.cpp old mode 100644 new mode 100755 diff --git a/src/blt/fs/loader.cpp b/src/blt/fs/loader.cpp old mode 100644 new mode 100755 diff --git a/src/blt/fs/nbt.cpp b/src/blt/fs/nbt.cpp old mode 100644 new mode 100755 diff --git a/src/blt/fs/nbt_block.cpp b/src/blt/fs/nbt_block.cpp old mode 100644 new mode 100755 diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp old mode 100644 new mode 100755 diff --git a/src/blt/profiling/profiler.cpp b/src/blt/profiling/profiler.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/format.cpp b/src/blt/std/format.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/logging.cpp b/src/blt/std/logging.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/string.cpp b/src/blt/std/string.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/system.cpp b/src/blt/std/system.cpp old mode 100644 new mode 100755 diff --git a/src/blt/window/window.cpp b/src/blt/window/window.cpp old mode 100644 new mode 100755 diff --git a/tests/clean.sh b/tests/clean.sh old mode 100644 new mode 100755 diff --git a/tests/src/binary_trees.h b/tests/src/binary_trees.h old mode 100644 new mode 100755 diff --git a/tests/src/hashmap_tests.h b/tests/src/hashmap_tests.h old mode 100644 new mode 100755 diff --git a/tests/src/logging.h b/tests/src/logging.h old mode 100644 new mode 100755 diff --git a/tests/src/main.cpp b/tests/src/main.cpp old mode 100644 new mode 100755 diff --git a/tests/src/nbt_tests.cpp b/tests/src/nbt_tests.cpp old mode 100644 new mode 100755 diff --git a/tests/src/nbt_tests.h b/tests/src/nbt_tests.h old mode 100644 new mode 100755 diff --git a/tests/src/profiling_tests.h b/tests/src/profiling_tests.h old mode 100644 new mode 100755 diff --git a/tests/src/queue_tests.h b/tests/src/queue_tests.h old mode 100644 new mode 100755 diff --git a/tests/test.sh b/tests/test.sh old mode 100644 new mode 100755