diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-21 11:38:41 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-21 11:39:07 +0300 |
commit | bc88f2006d8163be52a54191a4e553d566395c5e (patch) | |
tree | dc7b9baeb81fac179dcdf9a0eea771bccce74929 /source/blender/blenlib | |
parent | ea79dab0621a0ef992d6289a95e72329279f6383 (diff) |
Cleanup: remove vector adaptor data structure
This was used in early node based particle system development
but is not used anymore. The code also didn't match the standards
of other data structures in blenlib.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_vector_adaptor.hh | 88 | ||||
-rw-r--r-- | source/blender/blenlib/CMakeLists.txt | 1 |
2 files changed, 0 insertions, 89 deletions
diff --git a/source/blender/blenlib/BLI_vector_adaptor.hh b/source/blender/blenlib/BLI_vector_adaptor.hh deleted file mode 100644 index 82d731aacd8..00000000000 --- a/source/blender/blenlib/BLI_vector_adaptor.hh +++ /dev/null @@ -1,88 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -/** \file - * \ingroup bli - * - * A `blender::VectorAdaptor` is a container with a fixed maximum size and does not own the - * underlying memory. When an adaptor is constructed, you have to provide it with an uninitialized - * array that will be filled when elements are added to the vector. The vector adaptor is not able - * to grow. Therefore, it is undefined behavior to add more elements than fit into the provided - * buffer. - */ - -#include "BLI_span.hh" - -namespace blender { - -template<typename T> class VectorAdaptor { - private: - T *begin_; - T *end_; - T *capacity_end_; - - public: - VectorAdaptor() : begin_(nullptr), end_(nullptr), capacity_end_(nullptr) - { - } - - VectorAdaptor(T *data, int64_t capacity, int64_t size = 0) - : begin_(data), end_(data + size), capacity_end_(data + capacity) - { - } - - VectorAdaptor(MutableSpan<T> span) : VectorAdaptor(span.data(), span.size(), 0) - { - } - - void append(const T &value) - { - BLI_assert(end_ < capacity_end_); - new (end_) T(value); - end_++; - } - - void append(T &&value) - { - BLI_assert(end_ < capacity_end_); - new (end_) T(std::move(value)); - end_++; - } - - void append_n_times(const T &value, int64_t n) - { - BLI_assert(end_ + n <= capacity_end_); - uninitialized_fill_n(end_, n, value); - end_ += n; - } - - void extend(Span<T> values) - { - BLI_assert(end_ + values.size() <= capacity_end_); - uninitialized_copy_n(values.data(), values.size(), end_); - end_ += values.size(); - } - - int64_t capacity() const - { - return capacity_end_ - begin_; - } - - int64_t size() const - { - return end_ - begin_; - } - - bool is_empty() const - { - return begin_ == end_; - } - - bool is_full() const - { - return end_ == capacity_end_; - } -}; - -} // namespace blender diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 36acbd41ad7..e0d05f8c36a 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -333,7 +333,6 @@ set(SRC BLI_uuid.h BLI_uvproject.h BLI_vector.hh - BLI_vector_adaptor.hh BLI_vector_set.hh BLI_vector_set_slots.hh BLI_virtual_array.hh |