31 std::array<TypedBuffer<T>, Capacity>
values;
54 Segment *current_segment_ =
nullptr;
61 current_segment_ = other.current_segment_;
62 other.current_segment_ =
nullptr;
69 static_assert(std::is_trivially_destructible_v<ChunkedListSegment<int, 4>>);
70 if constexpr (!std::is_trivially_destructible_v<T>) {
71 for (
Segment *segment = current_segment_; segment; segment = segment->
next) {
73 T &value = *segment->values[i];
74 std::destroy_at(&value);
85 std::destroy_at(
this);
101 this->
append_as(allocator, std::move(value));
106 if (current_segment_ ==
nullptr || current_segment_->
size == SegmentCapacity) {
108 static_assert(std::is_trivially_destructible_v<Segment>);
110 new_segment->
next = current_segment_;
111 current_segment_ = new_segment;
113 T *value = &*current_segment_->
values[current_segment_->
size++];
114 new (value)
T(std::forward<Args>(args)...);
119 const Segment *segment_ =
nullptr;
128 if (index_ == segment_->
size) {
129 segment_ = segment_->
next;
137 return *segment_->
values[index_];
154 if (index_ == segment_->
size) {
155 segment_ = segment_->
next;
163 return *segment_->
values[index_];
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
destruct_ptr< T > construct(Args &&...args)
ConstIterator & operator++()
ConstIterator(const Segment *segment, int64_t index=0)
const T & operator*() const
MutableIterator & operator++()
MutableIterator(Segment *segment, int64_t index=0)
ChunkedList & operator=(ChunkedList &&other)
ChunkedList(ChunkedList &&other)
void append(LinearAllocator<> &allocator, const T &value)
void append_as(LinearAllocator<> &allocator, Args &&...args)
ConstIterator end() const
void append(LinearAllocator<> &allocator, T &&value)
ConstIterator begin() const
std::array< TypedBuffer< T >, Capacity > values
ChunkedListSegment * next