|
Blender
V2.93
|
#include <BLI_span.hh>
Public Types | |
| using | value_type = T |
| using | pointer = T * |
| using | const_pointer = const T * |
| using | reference = T & |
| using | const_reference = const T & |
| using | iterator = const T * |
| using | size_type = int64_t |
Public Member Functions | |
| constexpr | Span ()=default |
| constexpr | Span (const T *start, int64_t size) |
| template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< U, T >> * = nullptr> | |
| constexpr | Span (const U *start, int64_t size) |
| constexpr | Span (const std::initializer_list< T > &list) |
| constexpr | Span (const std::vector< T > &vector) |
| template<std::size_t N> | |
| constexpr | Span (const std::array< T, N > &array) |
| template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< U, T >> * = nullptr> | |
| constexpr | Span (Span< U > span) |
| constexpr Span | slice (int64_t start, int64_t size) const |
| constexpr Span | slice (IndexRange range) const |
| constexpr Span | drop_front (int64_t n) const |
| constexpr Span | drop_back (int64_t n) const |
| constexpr Span | take_front (int64_t n) const |
| constexpr Span | take_back (int64_t n) const |
| constexpr const T * | data () const |
| constexpr const T * | begin () const |
| constexpr const T * | end () const |
| constexpr std::reverse_iterator< const T * > | rbegin () const |
| constexpr std::reverse_iterator< const T * > | rend () const |
| constexpr const T & | operator[] (int64_t index) const |
| constexpr int64_t | size () const |
| constexpr bool | is_empty () const |
| constexpr int64_t | size_in_bytes () const |
| constexpr bool | contains (const T &value) const |
| constexpr bool | contains_ptr (const T *ptr) const |
| constexpr int64_t | count (const T &value) const |
| constexpr const T & | first () const |
| constexpr const T & | last () const |
| constexpr T | get (int64_t index, const T &fallback) const |
| constexpr bool | has_duplicates__linear_search () const |
| constexpr bool | intersects__linear_search (Span other) const |
| constexpr int64_t | first_index (const T &search_value) const |
| constexpr int64_t | first_index_try (const T &search_value) const |
| constexpr IndexRange | index_range () const |
| template<typename NewT > | |
| constexpr Span< NewT > | cast () const |
| template<typename PrintLineF > | |
| void | print_as_lines (std::string name, PrintLineF print_line) const |
| void | print_as_lines (std::string name) const |
Friends | |
| bool | operator== (const Span< T > a, const Span< T > b) |
| bool | operator!= (const Span< T > a, const Span< T > b) |
References an array of type T that is owned by someone else. The data in the array cannot be modified.
Definition at line 87 of file BLI_span.hh.
| using blender::Span< T >::const_pointer = const T * |
Definition at line 91 of file BLI_span.hh.
| using blender::Span< T >::const_reference = const T & |
Definition at line 93 of file BLI_span.hh.
| using blender::Span< T >::iterator = const T * |
Definition at line 94 of file BLI_span.hh.
| using blender::Span< T >::pointer = T * |
Definition at line 90 of file BLI_span.hh.
| using blender::Span< T >::reference = T & |
Definition at line 92 of file BLI_span.hh.
| using blender::Span< T >::size_type = int64_t |
Definition at line 95 of file BLI_span.hh.
| using blender::Span< T >::value_type = T |
Definition at line 89 of file BLI_span.hh.
|
constexprdefault |
Create a reference to an empty array.
Referenced by blender::Span< T >::drop_back(), blender::Span< T >::drop_front(), blender::Span< T >::slice(), blender::Span< T >::take_back(), and blender::Span< T >::take_front().
|
inlineconstexpr |
Definition at line 107 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::size().
|
inlineconstexpr |
Definition at line 113 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::size().
|
inlineconstexpr |
Reference an initializer_list. Note that the data in the initializer_list is only valid until the expression containing it is fully computed.
Do: call_function_with_array({1, 2, 3, 4});
Don't: Span<int> span = {1, 2, 3, 4}; call_function_with_array(span);
Definition at line 129 of file BLI_span.hh.
|
inlineconstexpr |
Definition at line 134 of file BLI_span.hh.
|
inlineconstexpr |
Definition at line 139 of file BLI_span.hh.
|
inlineconstexpr |
Support implicit conversions like the one below: Span<T *> -> Span<const T *>
Definition at line 148 of file BLI_span.hh.
References data_.
|
inlineconstexpr |
Definition at line 222 of file BLI_span.hh.
References data_.
Referenced by blender::IndexMask::begin(), blender::Span< T >::contains_ptr(), blender::Span< T >::rend(), and blender::tests::TEST().
|
inlineconstexpr |
Returns a new Span to the same underlying memory buffer. No conversions are done.
Definition at line 422 of file BLI_span.hh.
References BLI_assert, data_, and T.
Referenced by blender::nodes::MFNetworkTreeMap::add_try_match(), and blender::tests::TEST().
|
inlineconstexpr |
Does a linear search to see of the value is in the array. Returns true if it is, otherwise false.
Definition at line 279 of file BLI_span.hh.
Referenced by blender::Span< T >::intersects__linear_search(), and blender::tests::TEST().
|
inlineconstexpr |
Does a constant time check to see if the pointer points to a value in the referenced array. Return true if it is, otherwise false.
Definition at line 293 of file BLI_span.hh.
References blender::Span< T >::begin(), blender::Span< T >::end(), and ptr.
Referenced by blender::tests::TEST().
|
inlineconstexpr |
Does a linear search to count how often the value is in the array. Returns the number of occurrences.
Definition at line 302 of file BLI_span.hh.
Referenced by blender::nodes::separate_points_from_component(), and blender::tests::TEST().
|
inlineconstexpr |
Returns the pointer to the beginning of the referenced array. This may be nullptr when the size is zero.
Definition at line 217 of file BLI_span.hh.
References data_.
Referenced by blender::LinearAllocator< Allocator >::construct_array_copy(), blender::MutableSpan< T >::copy_from(), blender::Vector< T, InlineBufferCapacity, Allocator >::extend(), blender::VectorAdaptor< T >::extend(), blender::Vector< T, InlineBufferCapacity, Allocator >::extend_unchecked(), blender::nodes::geo_node_point_distribute_exec(), get_dupliface_transform_from_coords(), blender::gpu::Shader::print_log(), blender::Stack< T, InlineBufferCapacity, Allocator >::push_multiple(), blender::tests::TEST(), and blender::gpu::GLShader::transform_feedback_names_set().
|
inlineconstexpr |
Returns a new Span with n elements removed from the beginning. This invokes undefined behavior when n is negative.
Definition at line 184 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::Span().
Referenced by compute_geometry(), modifyGeometry(), node_errors_tooltip_fn(), and blender::tests::TEST().
|
inlineconstexpr |
Returns a new Span with n elements removed from the beginning. This invokes undefined behavior when n is negative.
Definition at line 173 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::Span().
Referenced by compute_geometry(), blender::InplacePriorityQueue< T, FirstHasHigherPriority >::inactive_indices(), blender::Stack< T, InlineBufferCapacity, Allocator >::push_multiple(), and blender::tests::TEST().
|
inlineconstexpr |
Definition at line 226 of file BLI_span.hh.
References data_.
Referenced by blender::Span< T >::contains_ptr(), blender::IndexMask::end(), and blender::Span< T >::rbegin().
|
inlineconstexpr |
Return a reference to the first element in the array. This invokes undefined behavior when the array is empty.
Definition at line 317 of file BLI_span.hh.
References BLI_assert, and data_.
Referenced by blender::IndexMask::as_range(), blender::IndexMask::is_range(), and blender::tests::TEST().
|
inlineconstexpr |
Returns the index of the first occurrence of the given value. This invokes undefined behavior when the value is not in the array.
Definition at line 390 of file BLI_span.hh.
References BLI_assert, and blender::Span< T >::first_index_try().
Referenced by blender::fn::MFFunctionNode::input_for_param(), blender::fn::MFFunctionNode::output_for_param(), and blender::tests::TEST().
|
inlineconstexpr |
Returns the index of the first occurrence of the given value or -1 if it does not exist.
Definition at line 400 of file BLI_span.hh.
References data_.
Referenced by blender::Span< T >::first_index().
|
inlineconstexpr |
Returns the element at the given index. If the index is out of range, return the fallback value.
Definition at line 337 of file BLI_span.hh.
References data_.
Referenced by compute_vertex_mask__armature_mode(), and blender::tests::TEST().
|
inlineconstexpr |
Check if the array contains duplicates. Does a linear search for every element. So the total running time is O(n^2). Only use this for small arrays.
Definition at line 349 of file BLI_span.hh.
References BLI_assert, data_, and T.
|
inlineconstexpr |
Utility to make it more convenient to iterate over all indices that can be used with this array.
Definition at line 414 of file BLI_span.hh.
Referenced by blender::nodes::MFNetworkTreeMap::add(), blender::fn::MFNetwork::add_dummy(), blender::nodes::calculate_uvs(), blender::nodes::compute_special_attributes(), copy_masked_polys_to_new_mesh(), copy_masked_vertices_to_new_mesh(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::draw_float_vector(), blender::fn::mf_network_optimization::find_nodes_based_on_mask(), generate_unique_instance_ids(), blender::bke::geometry_set_collect_recursive(), blender::string_search::get_shortest_word_index_that_startswith(), blender::string_search::get_word_index_that_fuzzy_matches(), blender::IndexMask::index_range(), blender::nodes::interpolate_attribute_corner(), blender::nodes::interpolate_attribute_point(), blender::nodes::proximity_calc(), blender::nodes::sample_mesh_surface(), blender::string_search::score_query_against_words(), blender::nodes::update_elimination_mask_based_on_density_factors(), and blender::nodes::update_elimination_mask_for_close_points().
|
inlineconstexpr |
Returns true when this and the other array have an element in common. This should only be called on small arrays, because it has a running time of O(n*m) where n and m are the sizes of the arrays.
Definition at line 371 of file BLI_span.hh.
References BLI_assert, blender::Span< T >::contains(), data_, and T.
|
inlineconstexpr |
Returns true if the size is zero.
Definition at line 262 of file BLI_span.hh.
Referenced by compute_geometry(), blender::LinearAllocator< Allocator >::construct_array_copy(), blender::compositor::NodeOperationBuilder::convertToOperations(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::draw_float_vector(), blender::Stack< T, InlineBufferCapacity, Allocator >::push_multiple(), and blender::tests::TEST().
|
inlineconstexpr |
Returns a reference to the last element in the array. This invokes undefined behavior when the array is empty.
Definition at line 327 of file BLI_span.hh.
References BLI_assert, and data_.
Referenced by blender::IndexMask::is_range(), blender::IndexMask::last(), blender::IndexMask::min_array_size(), node_errors_tooltip_fn(), and blender::tests::TEST().
|
inlineconstexpr |
Access an element in the array. This invokes undefined behavior when the index is out of bounds.
Definition at line 244 of file BLI_span.hh.
References BLI_assert, and data_.
|
inline |
A debug utility to print the content of the span. Every element be printed on a separate line.
Definition at line 460 of file BLI_span.hh.
References blender::Span< T >::print_as_lines(), and T.
|
inline |
A debug utility to print the content of the Span. Every element will be printed on a separate line using the given callback.
Definition at line 446 of file BLI_span.hh.
References T.
Referenced by blender::Span< T >::print_as_lines().
|
inlineconstexpr |
Definition at line 231 of file BLI_span.hh.
References blender::Span< T >::end().
Referenced by blender::tests::TEST().
|
inlineconstexpr |
Definition at line 235 of file BLI_span.hh.
References blender::Span< T >::begin().
Referenced by blender::tests::TEST().
|
inlineconstexpr |
Returns the number of elements in the referenced array.
Definition at line 254 of file BLI_span.hh.
Referenced by blender::fn::MFNetwork::add_dummy(), blender::IndexMask::as_range(), compute_masked_vertices(), blender::nodes::compute_special_attributes(), computed_masked_polygons(), blender::LinearAllocator< Allocator >::construct_array_copy(), blender::MutableSpan< T >::copy_from(), copy_masked_edges_to_new_mesh(), copy_masked_vertices_to_new_mesh(), blender::double3::cross_poly(), blender::gpu::ShaderInterface::debug_print(), blender::meshintersect::direct_mesh_boolean(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::draw_float_vector(), blender::VectorAdaptor< T >::extend(), generate_unique_instance_ids(), blender::nodes::geo_node_point_distribute_exec(), blender::nodes::DOutputSocket::get_active_corresponding_group_output_socket(), get_dupliface_transform_from_coords(), gpu_select_query_end(), blender::IndexMask::IndexMask(), blender::nodes::interpolate_attribute_corner(), blender::nodes::interpolate_attribute_face(), blender::nodes::interpolate_attribute_point(), blender::nodes::interpolate_existing_attributes(), blender::IndexMask::is_range(), blender::nodes::MFNetworkTreeMap::lookup_dummy(), blender::string_search::match_word_initials(), blender::IndexMask::min_array_size(), modifyGeometry(), blender::dot::NodeWithSocketsRef::NodeWithSocketsRef(), blender::gpu::Shader::print_log(), blender::Stack< T, InlineBufferCapacity, Allocator >::push_multiple(), blender::string_search::score_query_against_words(), blender::IndexMask::size(), blender::Span< T >::slice(), blender::Span< T >::Span(), spreadsheet_main_region_draw(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::SpreadsheetLayoutDrawer(), blender::tests::TEST(), blender::tests::test_ref_from_initializer_list(), and blender::gpu::GLShader::transform_feedback_names_set().
|
inlineconstexpr |
Returns the number of bytes referenced by this Span.
Definition at line 270 of file BLI_span.hh.
References T.
Referenced by blender::tests::TEST().
|
inlineconstexpr |
Definition at line 164 of file BLI_span.hh.
References blender::IndexRange::size(), blender::Span< T >::slice(), and blender::IndexRange::start().
|
inlineconstexpr |
Returns a contiguous part of the array. This invokes undefined behavior when the start or size is negative.
Definition at line 156 of file BLI_span.hh.
References BLI_assert, data_, min, blender::Span< T >::size(), and blender::Span< T >::Span().
Referenced by blender::Span< T >::slice(), and blender::tests::TEST().
|
inlineconstexpr |
Returns a new Span that only contains the last n elements. This invokes undefined behavior when n is negative.
Definition at line 206 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::Span().
Referenced by blender::tests::TEST().
|
inlineconstexpr |
Returns a new Span that only contains the first n elements. This invokes undefined behavior when n is negative.
Definition at line 195 of file BLI_span.hh.
References BLI_assert, data_, and blender::Span< T >::Span().
Referenced by blender::InplacePriorityQueue< T, FirstHasHigherPriority >::active_indices(), and blender::tests::TEST().
Definition at line 437 of file BLI_span.hh.
Definition at line 429 of file BLI_span.hh.