Blender V5.0
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 ()
void clear_and_shrink ()
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 >
Template Parameters
TType of the elements that are stored in the stack.
InlineBufferCapacityThe number of values that can be stored in this stack, without doing a heap allocation. Sometimes it can make sense to increase this value a lot. The memory in the inline buffer is not initialized when it is not needed.
AllocatorThe allocator used by this stack. Should rarely be changed, except when you don't want that MEM_* is used internally.

Definition at line 70 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 74 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 76 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 73 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 75 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 77 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 72 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 116 of file BLI_stack.hh.

Referenced by blender::Stack< T, InlineBufferCapacity, RawAllocator >< RawVector< FunctionRef< void()>, 0 >, 0 >::clear_and_shrink().

◆ 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 128 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.

◆ 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

Definition at line 162 of file BLI_stack.hh.

◆ ~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.

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.

◆ clear_and_shrink()

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

Removes all elements from the stack and frees any allocated memory.

Definition at line 335 of file BLI_stack.hh.

◆ 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

Returns true when the size is zero.

Definition at line 308 of file BLI_stack.hh.

Referenced by blender::compositor::add_output_nodes(), bmesh_find_doubles_by_distance_connected_impl(), blender::fn::build_multi_function_procedure_for_fields(), blender::index_mask::compute_eval_order(), blender::compositor::compute_number_of_needed_buffers(), blender::compositor::compute_schedule(), blender::deg::deg_graph_flush_visibility_flags(), blender::ed::greasepencil::dilate(), blender::ed::greasepencil::erode(), blender::index_mask::evaluate_coarse_and_split_until_segments_are_short(), blender::bke::node_structure_type_inferencing::find_dynamic_output_linked_inputs(), blender::bke::node_field_inferencing::find_group_output_dependencies(), blender::nodes::find_origin_sockets_through_contexts(), blender::nodes::geo_eval_log::GeoTreeLog::find_socket_value_log(), blender::nodes::find_target_sockets_through_contexts(), blender::fn::find_varying_fields(), blender::ed::greasepencil::flood_fill(), blender::geometry::foreach_connected_curve(), gpu_nodes_tag(), blender::bke::iter_backwards_ex(), iter_shader_to_rgba_depth_count(), menu_items_from_ui_create(), blender::ed::space_node::mute_links_exec(), blender::bke::node_is_connected_to_output(), blender::fn::multi_function::ValueAllocator::obtain_OneSingle(), blender::fn::multi_function::ValueAllocator::obtain_Span(), blender::fn::preprocess_field_tree(), blender::bke::greasepencil::LayerGroup::print_nodes(), blender::ComputeContext::print_stack(), blender::geometry::ramer_douglas_peucker(), blender::ed::greasepencil::ramer_douglas_peucker_simplify(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::bke::node_tree_runtime::toposort_from_start_node().

◆ 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 342 of file BLI_stack.hh.

Referenced by blender::tests::TEST(), blender::tests::TEST(), and 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.

◆ 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.

◆ 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

◆ 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.

◆ pop()

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

Remove and return the top-most element from the stack. This invokes undefined behavior when the stack is empty.

Definition at line 242 of file BLI_stack.hh.

Referenced by blender::compositor::add_output_nodes(), bmesh_find_doubles_by_distance_connected_impl(), blender::fn::build_multi_function_procedure_for_fields(), blender::index_mask::compute_eval_order(), blender::compositor::compute_number_of_needed_buffers(), blender::compositor::compute_schedule(), blender::deg::deg_graph_flush_visibility_flags(), blender::ed::greasepencil::dilate(), blender::ed::greasepencil::erode(), blender::index_mask::evaluate_coarse_and_split_until_segments_are_short(), blender::bke::node_structure_type_inferencing::find_dynamic_output_linked_inputs(), blender::bke::node_field_inferencing::find_group_output_dependencies(), blender::nodes::find_origin_sockets_through_contexts(), blender::nodes::geo_eval_log::GeoTreeLog::find_socket_value_log(), blender::nodes::find_target_sockets_through_contexts(), blender::fn::find_varying_fields(), blender::ed::greasepencil::flood_fill(), blender::geometry::foreach_connected_curve(), gpu_nodes_tag(), blender::bke::iter_backwards_ex(), iter_shader_to_rgba_depth_count(), menu_items_from_ui_create(), blender::ed::space_node::mute_links_exec(), blender::bke::node_is_connected_to_output(), blender::fn::multi_function::ValueAllocator::obtain_OneSingle(), blender::fn::multi_function::ValueAllocator::obtain_Span(), blender::fn::preprocess_field_tree(), blender::bke::greasepencil::LayerGroup::print_nodes(), blender::ComputeContext::print_stack(), blender::geometry::ramer_douglas_peucker(), blender::ed::greasepencil::ramer_douglas_peucker_simplify(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::bke::node_tree_runtime::toposort_from_start_node().

◆ 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

Add a new element to the top of the stack.

Definition at line 213 of file BLI_stack.hh.

Referenced by blender::compositor::add_file_output_nodes(), blender::compositor::add_output_nodes(), bmesh_find_doubles_by_distance_connected_impl(), blender::fn::build_multi_function_procedure_for_fields(), blender::index_mask::compute_eval_order(), blender::compositor::compute_number_of_needed_buffers(), blender::compositor::compute_schedule(), blender::deg::deg_graph_flush_visibility_flags(), blender::ed::greasepencil::dilate(), blender::ed::greasepencil::erode(), blender::index_mask::evaluate_coarse_and_split_until_segments_are_short(), blender::bke::node_structure_type_inferencing::find_dynamic_output_linked_inputs(), blender::bke::node_field_inferencing::find_group_output_dependencies(), blender::nodes::find_origin_sockets_through_contexts(), blender::nodes::geo_eval_log::GeoTreeLog::find_socket_value_log(), blender::nodes::find_target_sockets_through_contexts(), blender::fn::find_varying_fields(), blender::ed::greasepencil::flood_fill(), blender::geometry::foreach_connected_curve(), gpu_nodes_tag(), blender::bke::iter_backwards_ex(), iter_shader_to_rgba_depth_count(), menu_items_from_ui_create(), menu_types_add_from_keymap_items(), blender::bke::node_is_connected_to_output(), blender::fn::preprocess_field_tree(), blender::bke::greasepencil::LayerGroup::print_nodes(), blender::ComputeContext::print_stack(), blender::geometry::ramer_douglas_peucker(), blender::ed::greasepencil::ramer_douglas_peucker_simplify(), blender::fn::multi_function::ValueAllocator::release_value(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::bke::node_tree_runtime::toposort_from_start_node().

◆ 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

Definition at line 217 of file BLI_stack.hh.

◆ 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.

Referenced by blender::ed::space_node::mute_links_exec(), blender::tests::TEST(), blender::tests::TEST(), and 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

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