|
Blender V5.0
|
#include <BLI_vector_set.hh>
Public Types | |
| using | value_type = Key |
| using | pointer = Key * |
| using | const_pointer = const Key * |
| using | reference = Key & |
| using | const_reference = const Key & |
| using | iterator = Key * |
| using | const_iterator = const Key * |
| using | size_type = int64_t |
| using | VectorT = Vector<Key, default_inline_buffer_capacity(sizeof(Key)), Allocator> |
Public Member Functions | |
| VectorSet (Allocator allocator={}) noexcept | |
| VectorSet (Hash hash, IsEqual is_equal) | |
| VectorSet (NoExceptConstructor, Allocator allocator={}) | |
| VectorSet (Span< Key > keys, Allocator allocator={}) | |
| VectorSet (const std::initializer_list< Key > &keys, Allocator allocator={}) | |
| VectorSet (const VectorSet &other) | |
| template<int64_t OtherInlineBufferCapacity> | |
| VectorSet (VectorSet< Key, OtherInlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator > &&other) noexcept | |
| ~VectorSet () | |
| VectorSet & | operator= (const VectorSet &other) |
| VectorSet & | operator= (VectorSet &&other) |
| const Key & | operator[] (const int64_t index) const |
| operator Span< Key > () const | |
| Span< Key > | as_span () const |
| void | add_new (const Key &key) |
| void | add_new (Key &&key) |
| bool | add (const Key &key) |
| bool | add (Key &&key) |
| template<typename ForwardKey> | |
| bool | add_as (ForwardKey &&key) |
| bool | add_overwrite (const Key &key) |
| bool | add_overwrite (Key &&key) |
| template<typename ForwardKey> | |
| bool | add_overwrite_as (ForwardKey &&key) |
| void | add_multiple (Span< Key > keys) |
| bool | contains (const Key &key) const |
| template<typename ForwardKey> | |
| bool | contains_as (const ForwardKey &key) const |
| bool | remove (const Key &key) |
| template<typename ForwardKey> | |
| bool | remove_as (const ForwardKey &key) |
| void | remove_contained (const Key &key) |
| template<typename ForwardKey> | |
| void | remove_contained_as (const ForwardKey &key) |
| template<typename Predicate> | |
| int64_t | remove_if (Predicate &&predicate) |
| Key | pop () |
| int64_t | index_of (const Key &key) const |
| template<typename ForwardKey> | |
| int64_t | index_of_as (const ForwardKey &key) const |
| int64_t | index_of_try (const Key &key) const |
| template<typename ForwardKey> | |
| int64_t | index_of_try_as (const ForwardKey &key) const |
| int64_t | index_of_or_add (const Key &key) |
| int64_t | index_of_or_add (Key &&key) |
| template<typename ForwardKey> | |
| int64_t | index_of_or_add_as (ForwardKey &&key) |
| const Key & | lookup_key (const Key &key) const |
| template<typename ForwardKey> | |
| const Key & | lookup_key_as (const ForwardKey &key) const |
| Key | lookup_key_default (const Key &key, const Key &default_value) const |
| template<typename ForwardKey, typename... ForwardDefault> | |
| Key | lookup_key_default_as (const ForwardKey &key, ForwardDefault &&...default_key) const |
| const Key * | lookup_key_ptr (const Key &key) const |
| template<typename ForwardKey> | |
| const Key * | lookup_key_ptr_as (const ForwardKey &key) const |
| const Key * | data () const |
| const Key * | begin () const |
| const Key * | end () const |
| IndexRange | index_range () const |
| void | print_stats (const char *name) const |
| bool | is_inline () const |
| int64_t | size () const |
| bool | is_empty () const |
| int64_t | capacity () const |
| int64_t | removed_amount () const |
| int64_t | size_per_element () const |
| int64_t | size_in_bytes () const |
| void | reserve (const int64_t n) |
| void | clear () |
| void | clear_and_keep_capacity () |
| int64_t | count_collisions (const Key &key) const |
| VectorT | extract_vector () |
Friends | |
| template<typename Other, int64_t OtherInlineBufferCapacity, typename OtherProbingStrategy, typename OtherHash, typename OtherIsEqual, typename OtherSlot, typename OtherAllocator> | |
| class | VectorSet |
| Key | Type of the elements that are stored in this set. It has to be movable. Furthermore, the hash and is-equal functions have to support it. |
| InlineBufferCapacity | The number of values that can be stored in the container without a heap allocation. |
| ProbingStrategy | The strategy used to deal with collisions. They are defined in BLI_probing_strategies.hh. |
| Hash | The hash function used to hash the keys. There is a default for many types. See BLI_hash.hh for examples on how to define a custom hash function. |
| IsEqual | The equality operator used to compare keys. By default it will simply compare keys using the == operator. |
| Slot | This is what will actually be stored in the hash table array. At a minimum a slot has to be able to hold an array index and information about whether the slot is empty, occupied or removed. Using a non-standard slot type can improve performance for some types. Also see BLI_vector_set_slots.hh. |
| Allocator | The allocator used by this set. Should rarely be changed, except when you don't want that MEM_* etc. is used internally. |
Definition at line 92 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::const_iterator = const Key * |
Definition at line 100 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::const_pointer = const Key * |
Definition at line 96 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::const_reference = const Key & |
Definition at line 98 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::iterator = Key * |
Definition at line 99 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::pointer = Key * |
Definition at line 95 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reference = Key & |
Definition at line 97 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::size_type = int64_t |
Definition at line 101 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::value_type = Key |
Definition at line 94 of file BLI_vector_set.hh.
| using blender::VectorSet< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::VectorT = Vector<Key, default_inline_buffer_capacity(sizeof(Key)), Allocator> |
Definition at line 695 of file BLI_vector_set.hh.
|
inlinenoexcept |
Initialize an empty vector set. This is a cheap operation and won't do an allocation. This is necessary to avoid a high cost when no elements are added at all. An optimized grow operation is performed on the first insertion.
Definition at line 176 of file BLI_vector_set.hh.
|
inline |
Definition at line 186 of file BLI_vector_set.hh.
|
inline |
Definition at line 192 of file BLI_vector_set.hh.
|
inline |
Definition at line 194 of file BLI_vector_set.hh.
|
inline |
Construct a vector set that contains the given keys. Duplicates will be removed automatically.
Definition at line 202 of file BLI_vector_set.hh.
|
inline |
Definition at line 215 of file BLI_vector_set.hh.
|
inlinenoexcept |
Definition at line 243 of file BLI_vector_set.hh.
|
inline |
Definition at line 207 of file BLI_vector_set.hh.
|
inline |
Add a key to the vector set. If the key exists in the set already, nothing is done. The return value is true if the key was newly added.
This is similar to std::unordered_set::insert.
Definition at line 344 of file BLI_vector_set.hh.
Referenced by BKE_pbvh_bmesh_node_save_orig(), ntree_update_reroute_nodes(), object_duplilist_legacy_instances(), and blender::geometry::preprocess_meshes().
|
inline |
Definition at line 348 of file BLI_vector_set.hh.
|
inline |
Definition at line 352 of file BLI_vector_set.hh.
Referenced by blender::bke::id_hash::get_source_file_hash().
|
inline |
Convenience function to add many keys to the vector set at once. Duplicates are removed automatically.
We might be able to make this faster than sequentially adding all keys, but that is not implemented yet.
Definition at line 387 of file BLI_vector_set.hh.
|
inline |
Add a new key to the vector set. This invokes undefined behavior when the key is in the set already. When you know for certain that a key is not in the set yet, use this method for better performance. This also expresses the intent better.
Definition at line 329 of file BLI_vector_set.hh.
|
inline |
Definition at line 333 of file BLI_vector_set.hh.
|
inline |
Similar to add but reinserts the key if it already exists. Using this only makes sense if the key contains additional data besides what affects the hash.
Definition at line 367 of file BLI_vector_set.hh.
|
inline |
Definition at line 371 of file BLI_vector_set.hh.
|
inline |
Definition at line 375 of file BLI_vector_set.hh.
|
inline |
Get a Span referencing the keys vector. The referenced memory buffer is only valid as long as the vector set is not changed.
The keys must not be changed, because this would change their hash value.
Definition at line 319 of file BLI_vector_set.hh.
Referenced by blender::geometry::execute_realize_mesh_tasks(), and paintface_select_loop().
|
inline |
Definition at line 567 of file BLI_vector_set.hh.
Referenced by blender::geometry::preprocess_meshes().
|
inline |
Returns the number of available slots. This is mostly for debugging purposes.
Definition at line 618 of file BLI_vector_set.hh.
|
inline |
Remove all elements. Under some circumstances clear_and_keep_capacity may be more efficient.
Definition at line 661 of file BLI_vector_set.hh.
Referenced by blender::draw::DRW_curves_batch_cache_free_old(), blender::draw::DRW_mesh_batch_cache_create_requested(), blender::draw::DRW_mesh_batch_cache_free_old(), blender::draw::DRW_pointcloud_batch_cache_free_old(), and blender::draw::pointcloud_discard_attributes().
|
inline |
Remove all elements, but don't free the underlying memory.
This can be more efficient than using clear if approximately the same or more elements are added again afterwards. If way fewer elements are added instead, the cost of maintaining a large hash table can lead to very bad worst-case performance.
Definition at line 674 of file BLI_vector_set.hh.
|
inline |
Returns true if the key is in the vector set.
This is similar to std::unordered_set::find() != std::unordered_set::end().
Definition at line 399 of file BLI_vector_set.hh.
|
inline |
Definition at line 403 of file BLI_vector_set.hh.
|
inline |
Get the number of collisions that the probing strategy has to go through to find the key or determine that it is not in the set.
Definition at line 690 of file BLI_vector_set.hh.
|
inline |
Get a pointer to the beginning of the array containing all keys.
Definition at line 562 of file BLI_vector_set.hh.
Referenced by blender::geometry::execute_realize_grease_pencil_tasks().
|
inline |
Definition at line 572 of file BLI_vector_set.hh.
Referenced by blender::geometry::preprocess_meshes().
|
inline |
Extracts all inserted values as a Vector. The values are removed from the VectorSet. This takes O(1) time.
The caller does not need special handling for when the data is stored inline in the vector set.
One can use this to create a Vector without duplicates efficiently.
Definition at line 706 of file BLI_vector_set.hh.
|
inline |
Return the location of the key in the vector. It is assumed that the key is in the vector set. If this is not necessarily the case, use index_of_try.
Definition at line 470 of file BLI_vector_set.hh.
Referenced by BKE_pbvh_bmesh_node_save_orig(), blender::geometry::gather_realize_tasks_recursive(), ntree_update_reroute_nodes(), object_duplilist_legacy_instances(), and blender::geometry::preprocess_meshes().
|
inline |
Definition at line 474 of file BLI_vector_set.hh.
|
inline |
Return the index of the key in the vector. If the key is not in the set, add it and return its index.
Definition at line 496 of file BLI_vector_set.hh.
Referenced by blender::geometry::preprocess_grease_pencils().
|
inline |
Definition at line 500 of file BLI_vector_set.hh.
|
inline |
Definition at line 504 of file BLI_vector_set.hh.
|
inline |
Return the location of the key in the vector. If the key is not in the set, -1 is returned. If you know for sure that the key is in the set, it is better to use index_of instead.
Definition at line 483 of file BLI_vector_set.hh.
|
inline |
Definition at line 487 of file BLI_vector_set.hh.
|
inline |
Get an index range containing all valid indices for this array.
Definition at line 580 of file BLI_vector_set.hh.
Referenced by blender::draw::DRW_curves_texture_for_evaluated_attribute(), blender::draw::DRW_mesh_batch_cache_create_requested(), blender::draw::DRW_pointcloud_batch_cache_create_requested(), blender::draw::DRW_pointcloud_evaluated_attribute(), ntree_update_reroute_nodes(), blender::nodes::node_geo_split_to_instances_cc::split_curve_groups(), blender::nodes::node_geo_split_to_instances_cc::split_instance_groups(), and blender::nodes::node_geo_split_to_instances_cc::split_pointcloud_groups().
|
inline |
Returns true if no keys are stored.
Definition at line 610 of file BLI_vector_set.hh.
Referenced by blender::bke::id_hash::compute_linked_id_deep_hashes(), blender::geometry::execute_realize_grease_pencil_tasks(), and blender::geometry::initialize_curves_builtin_attribute_defaults().
|
inline |
Definition at line 594 of file BLI_vector_set.hh.
|
inline |
Returns the key that is stored in the vector set that compares equal to the given key. This invokes undefined behavior when the key is not in the set.
Definition at line 513 of file BLI_vector_set.hh.
|
inline |
Definition at line 517 of file BLI_vector_set.hh.
|
inline |
Returns the key that compares equal to the given key. If the key is not in the set, the given default value is returned instead.
Definition at line 528 of file BLI_vector_set.hh.
|
inline |
Definition at line 533 of file BLI_vector_set.hh.
|
inline |
Returns a pointer to the key that is stored in the vector set that compares equal to the given key. If the key is not in the set, null is returned.
Definition at line 546 of file BLI_vector_set.hh.
|
inline |
Definition at line 550 of file BLI_vector_set.hh.
|
inline |
Definition at line 308 of file BLI_vector_set.hh.
|
inline |
Definition at line 288 of file BLI_vector_set.hh.
|
inline |
Definition at line 293 of file BLI_vector_set.hh.
|
inline |
Get the key stored at the given position in the vector.
Definition at line 301 of file BLI_vector_set.hh.
|
inline |
Delete and return a key from the set. This will remove the last element in the vector. The order of the remaining elements in the set is not changed.
Definition at line 461 of file BLI_vector_set.hh.
|
inline |
Print common statistics like size and collision count. This is useful for debugging purposes.
Definition at line 588 of file BLI_vector_set.hh.
|
inline |
Deletes the key from the set. Returns true when the key existed in the set and is now removed. This might change the order of elements in the vector.
This is similar to std::unordered_set::erase.
Definition at line 414 of file BLI_vector_set.hh.
|
inline |
Definition at line 418 of file BLI_vector_set.hh.
|
inline |
Deletes the key from the set. This invokes undefined behavior when the key is not in the set. It might change the order of elements in the vector.
Definition at line 427 of file BLI_vector_set.hh.
|
inline |
Definition at line 431 of file BLI_vector_set.hh.
|
inline |
Remove all values for which the given predicate is true and return the number or values removed. This may change the order of elements in the vector.
This is similar to std::erase_if.
Definition at line 442 of file BLI_vector_set.hh.
|
inline |
Returns the amount of removed slots in the set. This is mostly for debugging purposes.
Definition at line 626 of file BLI_vector_set.hh.
|
inline |
Potentially resize the vector set such that it can hold n elements without doing another grow.
Definition at line 651 of file BLI_vector_set.hh.
Referenced by BKE_pbvh_bmesh_node_save_orig().
|
inline |
Returns the number of keys stored in the vector set.
Definition at line 602 of file BLI_vector_set.hh.
Referenced by blender::geometry::execute_realize_grease_pencil_tasks(), ntree_update_reroute_nodes(), blender::geometry::preprocess_curves(), blender::geometry::preprocess_grease_pencils(), blender::geometry::preprocess_meshes(), and blender::geometry::preprocess_pointclouds().
|
inline |
Returns the approximate memory requirements of the set in bytes. This is more correct for larger sets.
Definition at line 643 of file BLI_vector_set.hh.
|
inline |
Returns the bytes required per element. This is mostly for debugging purposes.
Definition at line 634 of file BLI_vector_set.hh.
|
friend |
Be a friend with other template instantiations. This is necessary to implement some memory management logic.
Definition at line 168 of file BLI_vector_set.hh.