35 std::array<TypedBuffer<T>, Capacity>
values;
58 Segment *current_segment_ =
nullptr;
65 current_segment_ = other.current_segment_;
66 other.current_segment_ =
nullptr;
73 static_assert(std::is_trivially_destructible_v<ChunkedListSegment<int, 4>>);
74 if constexpr (!std::is_trivially_destructible_v<T>) {
75 for (Segment *segment = current_segment_; segment; segment = segment->next) {
77 T &value = *segment->values[
i];
78 std::destroy_at(&value);
89 std::destroy_at(
this);
105 this->
append_as(allocator, std::move(value));
110 if (current_segment_ ==
nullptr || current_segment_->size == SegmentCapacity) {
112 static_assert(std::is_trivially_destructible_v<Segment>);
113 Segment *new_segment = allocator.
construct<Segment>().release();
114 new_segment->
next = current_segment_;
115 current_segment_ = new_segment;
117 T *value = &*current_segment_->values[current_segment_->size++];
118 new (value)
T(std::forward<Args>(args)...);
123 const Segment *segment_ =
nullptr;
132 if (index_ == segment_->size) {
133 segment_ = segment_->next;
141 return *segment_->values[index_];
149 Segment *segment_ =
nullptr;
158 if (index_ == segment_->size) {
159 segment_ = segment_->next;
167 return *segment_->values[index_];
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
destruct_ptr< T > construct(Args &&...args)
NonCopyable(const NonCopyable &other)=delete
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