Blender V5.3
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 ()
Stack & operator= (const Stack &other)
Stack & operator= (Stack &&other)
void push (const T &value)
void push (T &&value)
template<typename... ForwardT>
void push_as (ForwardT &&...value)
T pop ()
T & peek ()
const T & peek () 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 72 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 76 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 78 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 75 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 77 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 79 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 74 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

◆ 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 130 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 136 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 150 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 155 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 164 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 192 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 327 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 337 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 310 of file BLI_stack.hh.

Referenced by blender::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::fn::FieldHashDeep::ensure(), 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::nodes::find_origin_sockets_through_contexts(), blender::nodes::eval_log::NodeTreeLog::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(), blender::nodes::LazyFunctionForExtractingReferenceSet::gather_references_from_field(), blender::gpu_nodes_tag(), blender::nodes::node_geo_enable_output_cc::is_linked_to_group_output(), blender::bke::iter_backwards_ex(), blender::iter_shader_to_rgba_depth_count(), blender::kdtree_find_nearest_cb(), blender::kdtree_find_nearest_n_with_len_squared_cb(), blender::kdtree_range_search_cb(), blender::kdtree_range_search_with_len_squared_cb(), blender::lib_query_unused_ids_find_used_dependencies(), blender::loose_data_gather_instanciated_objects_for_viewlayer(), blender::ui::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::bke::pbvh::search_callback_occluded(), 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 344 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 202 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 207 of file BLI_stack.hh.

◆ peek() [1/2]

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

Referenced by blender::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::fn::FieldHashDeep::ensure(), 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::nodes::find_origin_sockets_through_contexts(), blender::nodes::eval_log::NodeTreeLog::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(), blender::nodes::LazyFunctionForExtractingReferenceSet::gather_references_from_field(), blender::gpu_nodes_tag(), blender::nodes::node_geo_enable_output_cc::is_linked_to_group_output(), blender::bke::iter_backwards_ex(), blender::iter_shader_to_rgba_depth_count(), blender::kdtree_find_nearest_cb(), blender::kdtree_find_nearest_n_with_len_squared_cb(), blender::kdtree_range_search_cb(), blender::kdtree_range_search_with_len_squared_cb(), blender::lib_query_unused_ids_find_used_dependencies(), blender::loose_data_gather_instanciated_objects_for_viewlayer(), blender::ui::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::bke::pbvh::search_callback_occluded(), 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(), blender::bke::node_tree_runtime::toposort_from_start_node(), and blender::lazy_threading::ReceiverIsolation::~ReceiverIsolation().

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

Referenced by blender::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::deg::deg_graph_flush_visibility_flags(), blender::ed::greasepencil::dilate(), blender::fn::FieldHashDeep::ensure(), 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::nodes::find_origin_sockets_through_contexts(), blender::nodes::eval_log::NodeTreeLog::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(), blender::nodes::LazyFunctionForExtractingReferenceSet::gather_references_from_field(), blender::compositor::get_output_nodes(), blender::gpu_nodes_tag(), blender::nodes::node_geo_enable_output_cc::is_linked_to_group_output(), blender::bke::iter_backwards_ex(), blender::iter_shader_to_rgba_depth_count(), blender::kdtree_find_nearest_cb(), blender::kdtree_find_nearest_n_with_len_squared_cb(), blender::kdtree_range_search_cb(), blender::kdtree_range_search_with_len_squared_cb(), blender::lib_query_unused_ids_find_used_dependencies(), blender::ui::menu_items_from_ui_create(), blender::ui::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::bke::pbvh::search_callback_occluded(), 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 219 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 283 of file BLI_stack.hh.

Referenced by blender::compositor::compute_schedule(), 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: