Blender V5.3
BLI_vector.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
26
27#include <algorithm>
28
29#include "BLI_allocator.hh"
30#include "BLI_index_range.hh"
31#include "BLI_memory_utils.hh"
32#include "BLI_span.hh"
33#include "BLI_utildefines.hh"
34
35namespace blender {
36
37namespace internal {
38void vector_print_stats(const char *name,
39 const void *address,
40 int64_t size,
42 int64_t inlineCapacity,
43 int64_t memorySize);
44}
45
50template<typename T, typename Allocator> struct VectorData {
51 T *data = nullptr;
55};
56
57template<
61 typename T,
70 int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)),
75 typename Allocator = GuardedAllocator>
76class Vector {
77 public:
78 using value_type = T;
79 using pointer = T *;
80 using const_pointer = const T *;
81 using reference = T &;
82 using const_reference = const T &;
83 using iterator = T *;
84 using const_iterator = const T *;
86 using allocator_type = Allocator;
87
88 private:
95 T *begin_;
96 T *end_;
97 T *capacity_end_;
98
100 BLI_NO_UNIQUE_ADDRESS Allocator allocator_;
101
104
110#ifndef NDEBUG
111 int64_t debug_size_;
112# define UPDATE_VECTOR_SIZE(ptr) (ptr)->debug_size_ = int64_t((ptr)->end_ - (ptr)->begin_)
113#else
114# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
115#endif
116
121 template<typename OtherT, int64_t OtherInlineBufferCapacity, typename OtherAllocator>
122 friend class Vector;
123
125 static constexpr bool is_nothrow_move_constructible()
126 {
127 if constexpr (InlineBufferCapacity == 0) {
128 return true;
129 }
130 else {
131 return std::is_nothrow_move_constructible_v<T>;
132 }
133 }
134
135 public:
140 Vector(Allocator allocator = {}) noexcept : allocator_(allocator)
141 {
142 begin_ = inline_buffer_;
143 end_ = begin_;
144 capacity_end_ = begin_ + InlineBufferCapacity;
145 UPDATE_VECTOR_SIZE(this);
146 }
147
148 Vector(NoExceptConstructor, Allocator allocator = {}) noexcept : Vector(allocator) {}
149
155 explicit Vector(int64_t size, Allocator allocator = {})
156 : Vector(NoExceptConstructor(), allocator)
157 {
158 this->resize(size);
159 }
160
164 Vector(int64_t size, const T &value, Allocator allocator = {})
165 : Vector(NoExceptConstructor(), allocator)
166 {
167 this->resize(size, value);
168 }
169
173 template<typename U>
174 Vector(Span<U> values, Allocator allocator = {})
175 requires(std::is_convertible_v<U, T>)
176 : Vector(NoExceptConstructor(), allocator)
177 {
178 const int64_t size = values.size();
179 this->reserve(size);
180 uninitialized_convert_n<U, T>(values.data(), size, begin_);
181 this->increase_size_by_unchecked(size);
182 }
183
184 template<typename U>
185 explicit Vector(MutableSpan<U> values, Allocator allocator = {})
186 requires(std::is_convertible_v<U, T>)
187 : Vector(values.as_span(), allocator)
188 {
189 }
190
197 template<typename U>
198 Vector(const std::initializer_list<U> &values)
199 requires(std::is_convertible_v<U, T>)
200 : Vector(Span<U>(values))
201 {
202 }
203
204 Vector(const std::initializer_list<T> &values) : Vector(Span<T>(values)) {}
205
206 template<typename U, size_t N>
207 Vector(const std::array<U, N> &values)
208 requires(std::is_convertible_v<U, T>)
209 : Vector(Span(values))
210 {
211 }
212
213 template<typename InputIt>
214 Vector(InputIt first, InputIt last, Allocator allocator = {})
215 /* This constructor should not be called with e.g. Vector(3, 10), because that is
216 * expected to produce the vector (10, 10, 10). */
217 requires(!std::is_convertible_v<InputIt, int>)
218 : Vector(NoExceptConstructor(), allocator)
219 {
220 for (InputIt current = first; current != last; ++current) {
221 this->append(*current);
222 }
223 }
224
229 Vector(const Vector &other) : Vector(other.as_span(), other.allocator_) {}
230
235 template<int64_t OtherInlineBufferCapacity>
237 : Vector(other.as_span(), other.allocator_)
238 {
239 }
240
245 template<int64_t OtherInlineBufferCapacity>
247 is_nothrow_move_constructible())
248 : Vector(NoExceptConstructor(), other.allocator_)
249 {
250 if (other.is_inline()) {
251 const int64_t size = other.size();
252
253 /* Optimize the case by copying the full inline buffer. */
254 constexpr bool other_is_same_type = std::is_same_v<Vector, std::decay_t<decltype(other)>>;
255 constexpr size_t max_full_copy_size = 32;
256 if constexpr (other_is_same_type && std::is_trivial_v<T> &&
257 sizeof(inline_buffer_) <= max_full_copy_size)
258 {
259 /* This check is technically optional. However, benchmarking shows that skipping work
260 * for empty vectors (which is a common case) is worth the extra check even in the case
261 * when the vector is not empty. */
262 if (size > 0) {
263 /* Copy the full inline buffer instead of only the used parts. This may copy
264 * uninitialized values but allows producing more optimal code than when the copy size
265 * would depend on a dynamic value. */
266 memcpy(inline_buffer_, other.inline_buffer_, sizeof(inline_buffer_));
267 this->increase_size_by_unchecked(size);
268 /* Reset other vector. */
269 other.end_ = other.inline_buffer_;
270 }
271 }
272 else {
273 /* This first check is not strictly necessary, but improves performance because it can be
274 * done at compile time and makes the size check at run-time unnecessary. */
275 if (OtherInlineBufferCapacity <= InlineBufferCapacity || size <= InlineBufferCapacity) {
276 /* Copy between inline buffers. */
277 uninitialized_relocate_n(other.begin_, size, begin_);
278 end_ = begin_ + size;
279 }
280 else {
281 /* Copy from inline buffer to newly allocated buffer. */
282 const int64_t capacity = size;
283 begin_ = static_cast<T *>(
284 allocator_.allocate(sizeof(T) * size_t(capacity), alignof(T), AT));
285 capacity_end_ = begin_ + capacity;
286 uninitialized_relocate_n(other.begin_, size, begin_);
287 end_ = begin_ + size;
288 }
289 /* Reset other vector. */
290 other.end_ = other.inline_buffer_;
291 }
292 }
293 else {
294 /* Steal the pointer. */
295 begin_ = other.begin_;
296 end_ = other.end_;
297 capacity_end_ = other.capacity_end_;
298
299 /* Reset other vector. */
300 other.begin_ = other.inline_buffer_;
301 other.end_ = other.inline_buffer_;
302 other.capacity_end_ = other.inline_buffer_ + OtherInlineBufferCapacity;
303 }
304
305 UPDATE_VECTOR_SIZE(this);
306 UPDATE_VECTOR_SIZE(&other);
307 }
308
315 {
316 BLI_assert(data.capacity == 0 || data.data != nullptr);
317 BLI_assert(data.size >= 0);
318 BLI_assert(data.size <= data.capacity);
319 /* Don't use the passed in buffer if it is null. Use the inline-buffer instead which is already
320 * initialized by the constructor call above. */
321 if (data.data != nullptr) {
322 /* Take ownership of the array. */
323 begin_ = data.data;
324 end_ = data.data + data.size;
325 capacity_end_ = data.data + data.capacity;
326 UPDATE_VECTOR_SIZE(this);
327 }
328 }
329
331 {
332 destruct_n(begin_, this->size());
333 if (!this->is_inline()) {
334 allocator_.deallocate(begin_);
335 }
336 }
337
338 Vector &operator=(const Vector &other)
339 {
340 return copy_assign_container(*this, other);
341 }
342
344 {
345 return move_assign_container(*this, std::move(other));
346 }
347
352 const T &operator[](int64_t index) const
353 {
354 BLI_assert(index >= 0);
356 return begin_[index];
357 }
358
360 {
361 BLI_assert(index >= 0);
363 return begin_[index];
364 }
365
366 operator Span<T>() const
367 {
368 return Span<T>(begin_, this->size());
369 }
370
371 operator MutableSpan<T>()
372 {
373 return MutableSpan<T>(begin_, this->size());
374 }
375
376 template<typename U>
377 operator Span<U>() const
379 {
380 return Span<U>(begin_, this->size());
381 }
382
383 template<typename U>
384 operator MutableSpan<U>()
386 {
387 return MutableSpan<U>(begin_, this->size());
388 }
389
391 {
392 return *this;
393 }
394
396 {
397 return *this;
398 }
399
405 void reserve(const int64_t min_capacity)
406 {
407 if (min_capacity > this->capacity()) {
408 this->realloc_to_at_least(min_capacity);
409 }
410 }
411
418 void resize(const int64_t new_size)
419 {
420 BLI_assert(new_size >= 0);
421 const int64_t old_size = this->size();
422 if (new_size > old_size) {
423 this->reserve(new_size);
424 default_construct_n(begin_ + old_size, new_size - old_size);
425 }
426 else {
427 destruct_n(begin_ + new_size, old_size - new_size);
428 }
429 end_ = begin_ + new_size;
430 UPDATE_VECTOR_SIZE(this);
431 }
432
439 void resize(const int64_t new_size, const T &value)
440 {
441 BLI_assert(new_size >= 0);
442 const int64_t old_size = this->size();
443 if (new_size > old_size) {
444 this->reserve(new_size);
445 uninitialized_fill_n(begin_ + old_size, new_size - old_size, value);
446 }
447 else {
448 destruct_n(begin_ + new_size, old_size - new_size);
449 }
450 end_ = begin_ + new_size;
451 UPDATE_VECTOR_SIZE(this);
452 }
453
458 void reinitialize(const int64_t new_size)
459 {
460 this->clear();
461 this->resize(new_size);
462 }
463
468 void clear()
469 {
470 destruct_n(begin_, this->size());
471 end_ = begin_;
472 UPDATE_VECTOR_SIZE(this);
473 }
474
480 {
481 destruct_n(begin_, this->size());
482 if (!this->is_inline()) {
483 allocator_.deallocate(begin_);
484 }
485
486 begin_ = inline_buffer_;
487 end_ = begin_;
488 capacity_end_ = begin_ + InlineBufferCapacity;
489 UPDATE_VECTOR_SIZE(this);
490 }
491
498 void append(const T &value)
499 {
500 this->append_as(value);
501 }
502 void append(T &&value)
503 {
504 this->append_as(std::move(value));
505 }
506 /* This is similar to `std::vector::emplace_back`. */
507 template<typename... ForwardValue> void append_as(ForwardValue &&...value)
508 {
509 this->ensure_space_for_one();
510 this->append_unchecked_as(std::forward<ForwardValue>(value)...);
511 }
512
518 {
519 return this->append_and_get_index_as(value);
520 }
522 {
523 return this->append_and_get_index_as(std::move(value));
524 }
525 template<typename... ForwardValue> int64_t append_and_get_index_as(ForwardValue &&...value)
526 {
527 const int64_t index = this->size();
528 this->append_as(std::forward<ForwardValue>(value)...);
529 return index;
530 }
531
537 void append_non_duplicates(const T &value)
538 {
539 if (!this->contains(value)) {
540 this->append(value);
541 }
542 }
543
549 void append_unchecked(const T &value)
550 {
551 this->append_unchecked_as(value);
552 }
553 void append_unchecked(T &&value)
554 {
555 this->append_unchecked_as(std::move(value));
556 }
557 template<typename... ForwardT> void append_unchecked_as(ForwardT &&...value)
558 {
559 BLI_assert(end_ < capacity_end_);
560 new (end_) T(std::forward<ForwardT>(value)...);
561 end_++;
562 UPDATE_VECTOR_SIZE(this);
563 }
564
569 void append_n_times(const T &value, const int64_t n)
570 {
571 BLI_assert(n >= 0);
572 this->reserve(this->size() + n);
573 uninitialized_fill_n(end_, n, value);
575 }
576
583 void increase_size_by_unchecked(const int64_t n) noexcept
584 {
585 BLI_assert(end_ + n <= capacity_end_);
586 end_ += n;
587 UPDATE_VECTOR_SIZE(this);
588 }
589
596 {
597 this->extend(array.data(), array.size());
598 }
599 void extend(const T *start, int64_t amount)
600 {
601 this->reserve(this->size() + amount);
602 this->extend_unchecked(start, amount);
603 }
604
613 template<int64_t OtherInlineBufferCapacity>
615 {
616 BLI_assert(this != &other);
617 this->extend(std::make_move_iterator(other.begin()), std::make_move_iterator(other.end()));
618 other.clear();
619 }
620
627 {
628 for (const T &value : array) {
629 this->append_non_duplicates(value);
630 }
631 }
632
638 {
640 }
641 void extend_unchecked(const T *start, int64_t amount)
642 {
643 BLI_assert(amount >= 0);
644 BLI_assert(begin_ + amount <= capacity_end_);
645 uninitialized_copy_n(start, amount, end_);
646 end_ += amount;
647 UPDATE_VECTOR_SIZE(this);
648 }
649
650 template<typename InputIt> void extend(InputIt first, InputIt last)
651 {
652 this->insert(this->end(), first, last);
653 }
654
660 void insert(const int64_t insert_index, const T &value)
661 {
662 this->insert(insert_index, Span<T>(&value, 1));
663 }
664 void insert(const int64_t insert_index, T &&value)
665 {
666 this->insert(
667 insert_index, std::make_move_iterator(&value), std::make_move_iterator(&value + 1));
668 }
669 void insert(const int64_t insert_index, Span<T> array)
670 {
671 this->insert(begin_ + insert_index, array.begin(), array.end());
672 }
673 template<typename InputIt> void insert(const T *insert_position, InputIt first, InputIt last)
674 {
675 const int64_t insert_index = insert_position - begin_;
676 this->insert(insert_index, first, last);
677 }
678 template<typename InputIt> void insert(const int64_t insert_index, InputIt first, InputIt last)
679 {
680 BLI_assert(insert_index >= 0);
681 BLI_assert(insert_index <= this->size());
682
683 const int64_t insert_amount = std::distance(first, last);
684 const int64_t old_size = this->size();
685 const int64_t new_size = old_size + insert_amount;
686 const int64_t move_amount = old_size - insert_index;
687
688 this->reserve(new_size);
689 for (int64_t i = 0; i < move_amount; i++) {
690 const int64_t src_index = insert_index + move_amount - i - 1;
691 const int64_t dst_index = new_size - i - 1;
692 try {
693 new (static_cast<void *>(begin_ + dst_index)) T(std::move(begin_[src_index]));
694 }
695 catch (...) {
696 /* Destruct all values that have been moved already. */
697 destruct_n(begin_ + dst_index + 1, i);
698 end_ = begin_ + src_index + 1;
699 UPDATE_VECTOR_SIZE(this);
700 throw;
701 }
702 begin_[src_index].~T();
703 }
704
705 try {
706 if constexpr (std::is_rvalue_reference_v<decltype(*first)>) {
707 std::uninitialized_move_n(first, insert_amount, begin_ + insert_index);
708 }
709 else {
710 std::uninitialized_copy_n(first, insert_amount, begin_ + insert_index);
711 }
712 }
713 catch (...) {
714 /* Destruct all values that have been moved. */
715 destruct_n(begin_ + new_size - move_amount, move_amount);
716 end_ = begin_ + insert_index;
717 UPDATE_VECTOR_SIZE(this);
718 throw;
719 }
720 end_ = begin_ + new_size;
721 UPDATE_VECTOR_SIZE(this);
722 }
723
728 void prepend(const T &value)
729 {
730 this->insert(0, value);
731 }
732 void prepend(T &&value)
733 {
734 this->insert(0, std::move(value));
735 }
736 void prepend(Span<T> values)
737 {
738 this->insert(0, values);
739 }
740 template<typename InputIt> void prepend(InputIt first, InputIt last)
741 {
742 this->insert(0, first, last);
743 }
744
749 const T &last(const int64_t n = 0) const
750 {
751 BLI_assert(n >= 0);
752 BLI_assert(n < this->size());
753 return *(end_ - 1 - n);
754 }
755 T &last(const int64_t n = 0)
756 {
757 BLI_assert(n >= 0);
758 BLI_assert(n < this->size());
759 return *(end_ - 1 - n);
760 }
761
766 const T &first() const
767 {
768 BLI_assert(this->size() > 0);
769 return *begin_;
770 }
772 {
773 BLI_assert(this->size() > 0);
774 return *begin_;
775 }
776
780 int64_t size() const
781 {
782 const int64_t current_size = int64_t(end_ - begin_);
783 BLI_assert(debug_size_ == current_size);
784 return current_size;
785 }
786
792 bool is_empty() const
793 {
794 return begin_ == end_;
795 }
796
802 {
803 BLI_assert(!this->is_empty());
804 end_--;
805 end_->~T();
806 UPDATE_VECTOR_SIZE(this);
807 }
808
816 {
817 BLI_assert(!this->is_empty());
818 T value = std::move(*(end_ - 1));
819 end_--;
820 end_->~T();
821 UPDATE_VECTOR_SIZE(this);
822 return value;
823 }
824
830 {
831 BLI_assert(index >= 0);
833 T *element_to_remove = begin_ + index;
834 T *last_element = end_ - 1;
835 if (element_to_remove < last_element) {
836 *element_to_remove = std::move(*last_element);
837 }
838 end_ = last_element;
839 last_element->~T();
840 UPDATE_VECTOR_SIZE(this);
841 }
842
848 {
849 const int64_t index = this->first_index_of(value);
851 }
852
860 void remove(const int64_t index)
861 {
862 BLI_assert(index >= 0);
864 const int64_t last_index = this->size() - 1;
865 for (int64_t i = index; i < last_index; i++) {
866 begin_[i] = std::move(begin_[i + 1]);
867 }
868 begin_[last_index].~T();
869 end_--;
870 UPDATE_VECTOR_SIZE(this);
871 }
872
879 void remove(const int64_t start_index, const int64_t amount)
880 {
881 const int64_t old_size = this->size();
882 BLI_assert(start_index >= 0);
883 BLI_assert(amount >= 0);
884 BLI_assert(start_index + amount <= old_size);
885 const int64_t move_amount = old_size - start_index - amount;
886 for (int64_t i = 0; i < move_amount; i++) {
887 begin_[start_index + i] = std::move(begin_[start_index + amount + i]);
888 }
889 destruct_n(end_ - amount, amount);
890 end_ -= amount;
891 UPDATE_VECTOR_SIZE(this);
892 }
893
900 template<typename Predicate> int64_t remove_if(Predicate &&predicate)
901 {
902 const T *prev_end = this->end();
903 end_ = std::remove_if(this->begin(), this->end(), predicate);
904 destruct_n(end_, prev_end - end_);
905 UPDATE_VECTOR_SIZE(this);
906 return int64_t(prev_end - end_);
907 }
908
913 int64_t first_index_of_try(const T &value) const
914 {
915 for (const T *current = begin_; current != end_; current++) {
916 if (*current == value) {
917 return int64_t(current - begin_);
918 }
919 }
920 return -1;
921 }
922
927 int64_t first_index_of(const T &value) const
928 {
929 const int64_t index = this->first_index_of_try(value);
930 BLI_assert(index >= 0);
931 return index;
932 }
933
938 bool contains(const T &value) const
939 {
940 return this->first_index_of_try(value) != -1;
941 }
942
946 void fill(const T &value) const
947 {
948 initialized_fill_n(begin_, this->size(), value);
949 }
950
955 {
956 return begin_;
957 }
958
962 const T *data() const
963 {
964 return begin_;
965 }
966
968 {
969 return begin_;
970 }
972 {
973 return end_;
974 }
975
976 const T *begin() const
977 {
978 return begin_;
979 }
980 const T *end() const
981 {
982 return end_;
983 }
984
985 std::reverse_iterator<T *> rbegin()
986 {
987 return std::reverse_iterator<T *>(this->end());
988 }
989 std::reverse_iterator<T *> rend()
990 {
991 return std::reverse_iterator<T *>(this->begin());
992 }
993
994 std::reverse_iterator<const T *> rbegin() const
995 {
996 return std::reverse_iterator<const T *>(this->end());
997 }
998 std::reverse_iterator<const T *> rend() const
999 {
1000 return std::reverse_iterator<const T *>(this->begin());
1001 }
1002
1008 {
1009 return int64_t(capacity_end_ - begin_);
1010 }
1011
1012 bool is_at_capacity() const
1013 {
1014 return end_ == capacity_end_;
1015 }
1016
1027 {
1028 return IndexRange(this->size());
1029 }
1030
1032 {
1033 return this->as_span().hash();
1034 }
1035
1036 static uint64_t hash_as(const Span<T> values)
1037 {
1038 return values.hash();
1039 }
1040
1041 friend bool operator==(const Vector &a, const Vector &b)
1042 {
1043 return a.as_span() == b.as_span();
1044 }
1045
1046 friend bool operator!=(const Vector &a, const Vector &b)
1047 {
1048 return !(a == b);
1049 }
1050
1061 {
1062 if (this->is_inline()) {
1063 if (this->is_empty()) {
1064 /* No need to make an allocation that does not contain any data. */
1065 return {};
1066 }
1067 /* Make an new allocation, because it's not possible to transfer ownership of the inline
1068 * buffer to the caller. */
1069 const int64_t size = this->size();
1070 T *data = static_cast<T *>(
1071 allocator_.allocate(size_t(size) * sizeof(T), alignof(T), __func__));
1072 try {
1074 }
1075 catch (...) {
1076 allocator_.deallocate(data);
1077 throw;
1078 }
1079 begin_ = data;
1080 end_ = begin_ + size;
1081 capacity_end_ = end_;
1082 }
1083
1085 data.data = begin_;
1086 data.size = end_ - begin_;
1087 data.capacity = capacity_end_ - begin_;
1088 data.allocator = allocator_;
1089
1090 /* Reset #Vector to use empty inline buffer again. */
1091 begin_ = inline_buffer_;
1092 end_ = begin_;
1093 capacity_end_ = begin_ + InlineBufferCapacity;
1094 UPDATE_VECTOR_SIZE(this);
1095
1096 return data;
1097 }
1098
1102 void print_stats(const char *name) const
1103 {
1105 name, this, this->size(), capacity_end_ - begin_, InlineBufferCapacity, sizeof(*this));
1106 }
1107
1108 bool is_inline() const
1109 {
1110 return begin_ == inline_buffer_;
1111 }
1112
1113 private:
1114 void ensure_space_for_one()
1115 {
1116 if (end_ >= capacity_end_) [[unlikely]] {
1117 this->realloc_to_at_least(this->size() + 1);
1118 }
1119 }
1120
1121 BLI_NOINLINE void realloc_to_at_least(const int64_t min_capacity)
1122 {
1123 if (this->capacity() >= min_capacity) {
1124 return;
1125 }
1126
1127 /* At least double the size of the previous allocation. Otherwise consecutive calls to grow can
1128 * cause a reallocation every time even though min_capacity only increments. */
1129 const int64_t min_new_capacity = this->capacity() * 2;
1130
1131 const int64_t new_capacity = std::max(min_capacity, min_new_capacity);
1132 const int64_t size = this->size();
1133
1134 T *new_array = static_cast<T *>(
1135 allocator_.allocate(size_t(new_capacity) * sizeof(T), alignof(T), AT));
1136 try {
1137 uninitialized_relocate_n(begin_, size, new_array);
1138 }
1139 catch (...) {
1140 allocator_.deallocate(new_array);
1141 throw;
1142 }
1143
1144 if (!this->is_inline()) {
1145 allocator_.deallocate(begin_);
1146 }
1147
1148 begin_ = new_array;
1149 end_ = begin_ + size;
1150 capacity_end_ = begin_ + new_capacity;
1151 }
1152};
1153
1154#undef UPDATE_VECTOR_SIZE
1155
1160template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T))>
1162
1163template<typename T> static constexpr bool is_Vector_v = false;
1164template<typename T, int64_t InlineBufferCapacity, typename Allocator>
1166
1167} // namespace blender
#define UPDATE_VECTOR_SIZE(ptr)
#define BLI_NOINLINE
#define AT
#define BLI_NO_UNIQUE_ADDRESS
long long int int64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
constexpr Span()=default
size_t size() const
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr uint64_t hash() const
Definition BLI_span.hh:410
void insert(const int64_t insert_index, T &&value)
std::reverse_iterator< const T * > rbegin() const
std::reverse_iterator< T * > rbegin()
void remove_and_reorder(const int64_t index)
Vector(const Vector< T, OtherInlineBufferCapacity, Allocator > &other)
void print_stats(const char *name) const
int64_t remove_if(Predicate &&predicate)
Vector(const Vector &other)
Vector(Allocator allocator={}) noexcept
int64_t append_and_get_index(const T &value)
void prepend(const T &value)
bool contains(const SubdivCCGCoord &value) const
Vector & operator=(Vector &&other)
bool is_at_capacity() const
void append(const T &value)
void insert(const int64_t insert_index, const SubdivCCGCoord &value)
friend bool operator==(const Vector &a, const Vector &b)
void prepend(T &&value)
const SubdivCCGCoord & last(const int64_t n=0) const
void append_unchecked_as(ForwardT &&...value)
void remove(const int64_t index)
uint64_t hash() const
friend class Vector
bool is_empty() const
void resize(const int64_t new_size, const T &value)
void remove_first_occurrence_and_reorder(const T &value)
IndexRange index_range() const
Vector(const std::initializer_list< U > &values)
int64_t append_and_get_index_as(ForwardValue &&...value)
Vector(InputIt first, InputIt last, Allocator allocator={})
void prepend(InputIt first, InputIt last)
Vector(const VectorData< T, Allocator > &data)
void resize(const int64_t new_size)
int64_t first_index_of(const SubdivCCGCoord &value) const
MutableSpan< T > as_mutable_span()
void extend_unchecked(Span< SubdivCCGCoord > array)
T & operator[](int64_t index)
void append_unchecked(const T &value)
void prepend(Span< T > values)
void extend(Vector< T, OtherInlineBufferCapacity, Allocator > &&other)
static uint64_t hash_as(const Span< T > values)
Vector(NoExceptConstructor, Allocator allocator={}) noexcept
const T & operator[](int64_t index) const
void reserve(const int64_t min_capacity)
const SubdivCCGCoord & const_reference
Definition BLI_vector.hh:82
const T * end() const
std::reverse_iterator< T * > rend()
void remove(const int64_t start_index, const int64_t amount)
void extend(Span< T > array)
void append(T &&value)
std::reverse_iterator< const T * > rend() const
void insert(const T *insert_position, InputIt first, InputIt last)
void append_unchecked(T &&value)
void extend_non_duplicates(Span< T > array)
Vector & operator=(const Vector &other)
void reinitialize(const int64_t new_size)
Vector(int64_t size, const T &value, Allocator allocator={})
void append_non_duplicates(const T &value)
void fill(const T &value) const
void insert(const int64_t insert_index, InputIt first, InputIt last)
Span< T > as_span() const
const T * data() const
Vector(int64_t size, Allocator allocator={})
const SubdivCCGCoord * const_pointer
Definition BLI_vector.hh:80
Vector(Span< U > values, Allocator allocator={})
const SubdivCCGCoord & first() const
T & last(const int64_t n=0)
void insert(const int64_t insert_index, Span< T > array)
Vector(Vector< T, OtherInlineBufferCapacity, Allocator > &&other) noexcept(is_nothrow_move_constructible())
Vector(const std::array< U, N > &values)
void append_as(ForwardValue &&...value)
int64_t append_and_get_index(T &&value)
void extend(InputIt first, InputIt last)
void extend(const T *start, int64_t amount)
void clear_and_shrink()
friend bool operator!=(const Vector &a, const Vector &b)
VectorData< T, Allocator > release()
void extend_unchecked(const T *start, int64_t amount)
void increase_size_by_unchecked(const int64_t n) noexcept
Vector(MutableSpan< U > values, Allocator allocator={})
const T * begin() const
int64_t first_index_of_try(const T &value) const
void append_n_times(const T &value, const int64_t n)
const SubdivCCGCoord * const_iterator
Definition BLI_vector.hh:84
Vector(const std::initializer_list< T > &values)
#define index(i)
#define capacity(const)
#define T
void vector_print_stats(const char *name, const void *address, int64_t size, int64_t capacity, int64_t inlineCapacity, int64_t memorySize)
Definition vector.cc:16
BMesh Iterators.
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
Definition BKE_text.h:91
__int64 int64_t
Definition BKE_text.h:90
void default_construct_n(T *ptr, int64_t n)
void initialized_fill_n(T *dst, int64_t n, const T &value)
Container & copy_assign_container(Container &dst, const Container &src)
Container & move_assign_container(Container &dst, Container &&src) noexcept(std::is_nothrow_move_constructible_v< Container >)
Vector< T, InlineBufferCapacity, RawAllocator > RawVector
constexpr int64_t default_inline_buffer_capacity(size_t element_size)
void uninitialized_fill_n(T *dst, int64_t n, const T &value)
void uninitialized_relocate_n(T *src, int64_t n, T *dst)
static constexpr bool is_Vector_v
void uninitialized_convert_n(const From *src, int64_t n, To *dst)
void destruct_n(T *ptr, int64_t n)
constexpr bool is_span_convertible_pointer_v
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
BLI_NO_UNIQUE_ADDRESS Allocator allocator
Definition BLI_vector.hh:54