34 std::array<TypedBuffer<T>, Capacity>
values;
60 Segment *current_segment_ =
nullptr;
67 current_segment_ = other.current_segment_;
68 other.current_segment_ =
nullptr;
73 static_assert(std::is_trivially_destructible_v<ChunkedListSegment<int, 4>>);
77 requires std::is_trivially_destructible_v<
T>
82 requires(!std::is_trivially_destructible_v<
T>)
84 for (
Segment *segment = current_segment_; segment; segment = segment->next) {
86 T &value = *segment->values[i];
87 std::destroy_at(&value);
97 std::destroy_at(
this);
113 this->
append_as(allocator, std::move(value));
118 if (current_segment_ ==
nullptr || current_segment_->size == SegmentCapacity) {
120 static_assert(std::is_trivially_destructible_v<Segment>);
122 new_segment->
next = current_segment_;
123 current_segment_ = new_segment;
125 T *value = &*current_segment_->values[current_segment_->size++];
126 new (value)
T(std::forward<Args>(args)...);
142 segment_ = segment_->next;
143 index_ = segment_ ? segment_->size - 1 : -1;
150 return *segment_->values[index_];
169 segment_ = segment_->next;
170 index_ = segment_ ? segment_->size - 1 : -1;
177 return *segment_->values[index_];
190 return ConstIterator(current_segment_, current_segment_ ? current_segment_->size - 1 : -1);
200 return MutableIterator(current_segment_, current_segment_ ? current_segment_->size - 1 : -1);
constexpr IndexRange()=default
destruct_ptr< T > construct(Args &&...args)
NonCopyable(const NonCopyable &other)=delete
ConstIterator & operator++()
const T & operator*() const
friend bool operator==(const ConstIterator &a, const ConstIterator &b)=default
ConstIterator(const Segment *segment, int64_t index)
MutableIterator & operator++()
MutableIterator(Segment *segment, int64_t index)
friend bool operator==(const MutableIterator &a, const MutableIterator &b)=default
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)
ChunkedListSegment< T, SegmentCapacity > Segment
ConstIterator begin() const
std::array< TypedBuffer< T >, Capacity > values
ChunkedListSegment * next