Blender  V3.3
Public Types | Public Member Functions | List of all members
blender::Stack< T, InlineBufferCapacity, Allocator > Class Template Reference

#include <BLI_stack.hh>

Public Types

using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using size_type = int64_t
 

Public Member Functions

 Stack (Allocator allocator={}) noexcept
 
 Stack (NoExceptConstructor, Allocator allocator={}) noexcept
 
 Stack (Span< T > values, Allocator allocator={})
 
 Stack (const std::initializer_list< T > &values, Allocator allocator={})
 
 Stack (const Stack &other)
 
 Stack (Stack &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 
 ~Stack ()
 
Stackoperator= (const Stack &other)
 
Stackoperator= (Stack &&other)
 
void push (const T &value)
 
void push (T &&value)
 
template<typename... ForwardT>
void push_as (ForwardT &&...value)
 
T pop ()
 
Tpeek ()
 
const Tpeek () const
 
void push_multiple (Span< T > values)
 
bool is_empty () const
 
int64_t size () const
 
void clear ()
 
bool is_invariant_maintained () const
 

Detailed Description

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
class blender::Stack< T, InlineBufferCapacity, Allocator >

Definition at line 68 of file BLI_stack.hh.

Member Typedef Documentation

◆ const_pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::const_pointer = const T *

Definition at line 72 of file BLI_stack.hh.

◆ const_reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::const_reference = const T &

Definition at line 74 of file BLI_stack.hh.

◆ pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::pointer = T *

Definition at line 71 of file BLI_stack.hh.

◆ reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::reference = T &

Definition at line 73 of file BLI_stack.hh.

◆ size_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::size_type = int64_t

Definition at line 75 of file BLI_stack.hh.

◆ value_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Stack< T, InlineBufferCapacity, Allocator >::value_type = T

Definition at line 70 of file BLI_stack.hh.

Constructor & Destructor Documentation

◆ Stack() [1/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( Allocator  allocator = {})
inlinenoexcept

Initialize an empty stack. No heap allocation is done.

Definition at line 114 of file BLI_stack.hh.

◆ Stack() [2/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( NoExceptConstructor  ,
Allocator  allocator = {} 
)
inlinenoexcept

Definition at line 126 of file BLI_stack.hh.

◆ Stack() [3/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( Span< T values,
Allocator  allocator = {} 
)
inline

Create a new stack that contains the given elements. The values are pushed to the stack in the order they are in the array.

Definition at line 134 of file BLI_stack.hh.

◆ Stack() [4/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( const std::initializer_list< T > &  values,
Allocator  allocator = {} 
)
inline

Create a new stack that contains the given elements. The values are pushed to the stack in the order they are in the array.

Example: Stack<int> stack = {4, 5, 6}; assert(stack.pop() == 6); assert(stack.pop() == 5);

Definition at line 148 of file BLI_stack.hh.

◆ Stack() [5/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( const Stack< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 153 of file BLI_stack.hh.

References blender::StackChunk< T >::above, and T.

◆ Stack() [6/6]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::Stack ( Stack< T, InlineBufferCapacity, Allocator > &&  other)
inlinenoexcept

◆ ~Stack()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Stack< T, InlineBufferCapacity, Allocator >::~Stack ( )
inline

Definition at line 190 of file BLI_stack.hh.

References blender::StackChunk< T >::above.

Member Function Documentation

◆ clear()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Stack< T, InlineBufferCapacity, Allocator >::clear ( )
inline

Removes all elements from the stack. The memory is not freed, so it is more efficient to reuse the stack than to create a new one.

Definition at line 325 of file BLI_stack.hh.

References blender::StackChunk< T >::begin.

◆ is_empty()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool blender::Stack< T, InlineBufferCapacity, Allocator >::is_empty ( ) const
inline

◆ is_invariant_maintained()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool blender::Stack< T, InlineBufferCapacity, Allocator >::is_invariant_maintained ( ) const
inline

Definition at line 333 of file BLI_stack.hh.

References blender::StackChunk< T >::begin.

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

◆ operator=() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Stack& blender::Stack< T, InlineBufferCapacity, Allocator >::operator= ( const Stack< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 200 of file BLI_stack.hh.

References blender::copy_assign_container().

◆ operator=() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Stack& blender::Stack< T, InlineBufferCapacity, Allocator >::operator= ( Stack< T, InlineBufferCapacity, Allocator > &&  other)
inline

Definition at line 205 of file BLI_stack.hh.

References blender::move_assign_container().

◆ peek() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Stack< T, InlineBufferCapacity, Allocator >::peek ( )
inline

Get a reference to the top-most element without removing it from the stack. This invokes undefined behavior when the stack is empty.

Definition at line 263 of file BLI_stack.hh.

References blender::StackChunk< T >::begin, and BLI_assert.

Referenced by blender::fn::build_multi_function_procedure_for_fields(), blender::fn::InstructionScheduler::peek(), blender::tests::TEST(), blender::nodes::toposort_from_start_node(), and blender::fn::InstructionScheduler::update_instruction_pointer().

◆ peek() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Stack< T, InlineBufferCapacity, Allocator >::peek ( ) const
inline

Definition at line 269 of file BLI_stack.hh.

References blender::StackChunk< T >::begin, and BLI_assert.

◆ pop()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T blender::Stack< T, InlineBufferCapacity, Allocator >::pop ( )
inline

◆ push() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Stack< T, InlineBufferCapacity, Allocator >::push ( const T value)
inline

◆ push() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Stack< T, InlineBufferCapacity, Allocator >::push ( T &&  value)
inline

◆ push_as()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename... ForwardT>
void blender::Stack< T, InlineBufferCapacity, Allocator >::push_as ( ForwardT &&...  value)
inline

◆ push_multiple()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Stack< T, InlineBufferCapacity, Allocator >::push_multiple ( Span< T values)
inline

Add multiple elements to the stack. The values are pushed in the order they are in the array. This method is more efficient than pushing multiple elements individually and might cause less heap allocations.

Definition at line 281 of file BLI_stack.hh.

References blender::StackChunk< T >::capacity_end, blender::Span< T >::data(), blender::Span< T >::drop_front(), blender::Span< T >::is_empty(), min, blender::Span< T >::size(), and blender::uninitialized_copy_n().

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

◆ size()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
int64_t blender::Stack< T, InlineBufferCapacity, Allocator >::size ( ) const
inline

Returns the number of elements in the stack.

Definition at line 316 of file BLI_stack.hh.

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


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