Blender V5.3
blender::linear_allocator::ChunkedList< T, SegmentCapacity > Class Template Reference

#include <BLI_linear_allocator_chunked_list.hh>

Inherits blender::blender::NonCopyable.

Classes

class  ConstIterator
class  MutableIterator

Public Types

using Segment = ChunkedListSegment<T, SegmentCapacity>

Public Member Functions

 ChunkedList ()=default
 ChunkedList (ChunkedList &&other)
 ~ChunkedList ()=default
 ~ChunkedList ()
ChunkedList & operator= (ChunkedList &&other)
void append (LinearAllocator<> &allocator, const T &value)
void append (LinearAllocator<> &allocator, T &&value)
template<typename... Args>
void append_as (LinearAllocator<> &allocator, Args &&...args)
ConstIterator begin () const
ConstIterator end () const
MutableIterator begin ()
MutableIterator end ()

Detailed Description

template<typename T, int64_t SegmentCapacity = 4>
class blender::linear_allocator::ChunkedList< T, SegmentCapacity >

This is a special purpose container data structure that can be used to efficiently gather many elements into many (small) lists for later retrieval. The values are iterated in inverse order of insertion.

To use this data structure, one has to have a separate LinearAllocator which is passed to the append function. This allows the same allocator to be used by many lists. Passing it into the append function also removes the need to store the allocator pointer in every list.

It is an improvement over Vector because it does not require any reallocations. VectorList could also be used to overcome the reallocation issue.

This data structure is also an improvement over VectorList because:

  • It has a much lower memory footprint when empty.
  • Allows using a LinearAllocator for all allocations, without storing the pointer to it in every vector.
  • It wastes less memory due to over-allocations.

Definition at line 55 of file BLI_linear_allocator_chunked_list.hh.

Member Typedef Documentation

◆ Segment

template<typename T, int64_t SegmentCapacity = 4>
using blender::linear_allocator::ChunkedList< T, SegmentCapacity >::Segment = ChunkedListSegment<T, SegmentCapacity>

Definition at line 57 of file BLI_linear_allocator_chunked_list.hh.

Constructor & Destructor Documentation

◆ ChunkedList() [1/2]

template<typename T, int64_t SegmentCapacity = 4>
blender::linear_allocator::ChunkedList< T, SegmentCapacity >::ChunkedList ( )
default

◆ ChunkedList() [2/2]

template<typename T, int64_t SegmentCapacity = 4>
blender::linear_allocator::ChunkedList< T, SegmentCapacity >::ChunkedList ( ChunkedList< T, SegmentCapacity > && other)
inline

Definition at line 65 of file BLI_linear_allocator_chunked_list.hh.

◆ ~ChunkedList() [1/2]

template<typename T, int64_t SegmentCapacity = 4>
blender::linear_allocator::ChunkedList< T, SegmentCapacity >::~ChunkedList ( )
default

If the contained type is trivially destructible, the entire ChunkedList is too.

◆ ~ChunkedList() [2/2]

template<typename T, int64_t SegmentCapacity = 4>
blender::linear_allocator::ChunkedList< T, SegmentCapacity >::~ChunkedList ( )
inline

If the contained type is not trivially destructible, all the elements are destructed.

Definition at line 81 of file BLI_linear_allocator_chunked_list.hh.

Member Function Documentation

◆ append() [1/2]

template<typename T, int64_t SegmentCapacity = 4>
void blender::linear_allocator::ChunkedList< T, SegmentCapacity >::append ( LinearAllocator<> & allocator,
const T & value )
inline

Add an element to the list. The given allocator is used to allocate any extra memory that may be needed.

Definition at line 106 of file BLI_linear_allocator_chunked_list.hh.

Referenced by blender::linear_allocator::tests::TEST().

◆ append() [2/2]

template<typename T, int64_t SegmentCapacity = 4>
void blender::linear_allocator::ChunkedList< T, SegmentCapacity >::append ( LinearAllocator<> & allocator,
T && value )
inline

Definition at line 111 of file BLI_linear_allocator_chunked_list.hh.

◆ append_as()

template<typename T, int64_t SegmentCapacity = 4>
template<typename... Args>
void blender::linear_allocator::ChunkedList< T, SegmentCapacity >::append_as ( LinearAllocator<> & allocator,
Args &&... args )
inline

Definition at line 116 of file BLI_linear_allocator_chunked_list.hh.

◆ begin() [1/2]

template<typename T, int64_t SegmentCapacity = 4>
MutableIterator blender::linear_allocator::ChunkedList< T, SegmentCapacity >::begin ( )
inline

Definition at line 198 of file BLI_linear_allocator_chunked_list.hh.

◆ begin() [2/2]

template<typename T, int64_t SegmentCapacity = 4>
ConstIterator blender::linear_allocator::ChunkedList< T, SegmentCapacity >::begin ( ) const
inline

Iterators over the elements in the list.

Note: The values are always iterated over in the inverse order of insertion!

Definition at line 188 of file BLI_linear_allocator_chunked_list.hh.

◆ end() [1/2]

template<typename T, int64_t SegmentCapacity = 4>
MutableIterator blender::linear_allocator::ChunkedList< T, SegmentCapacity >::end ( )
inline

Definition at line 203 of file BLI_linear_allocator_chunked_list.hh.

◆ end() [2/2]

template<typename T, int64_t SegmentCapacity = 4>
ConstIterator blender::linear_allocator::ChunkedList< T, SegmentCapacity >::end ( ) const
inline

Definition at line 193 of file BLI_linear_allocator_chunked_list.hh.

◆ operator=()

template<typename T, int64_t SegmentCapacity = 4>
ChunkedList & blender::linear_allocator::ChunkedList< T, SegmentCapacity >::operator= ( ChunkedList< T, SegmentCapacity > && other)
inline

Definition at line 92 of file BLI_linear_allocator_chunked_list.hh.


The documentation for this class was generated from the following file: