Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_set.hh')
-rw-r--r--source/blender/blenlib/BLI_set.hh34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index 06b56c3f8e5..fef657b2d8f 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -119,6 +119,16 @@ template<
*/
typename Allocator = GuardedAllocator>
class Set {
+ public:
+ class Iterator;
+ using value_type = Key;
+ using pointer = Key *;
+ using const_pointer = const Key *;
+ using reference = Key &;
+ using const_reference = const Key &;
+ using iterator = Iterator;
+ using size_type = int64_t;
+
private:
/**
* Slots are either empty, occupied or removed. The number of occupied slots can be computed by
@@ -401,6 +411,13 @@ class Set {
* also change their hash.
*/
class Iterator {
+ public:
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = Key;
+ using pointer = const Key *;
+ using reference = const Key &;
+ using difference_type = std::ptrdiff_t;
+
private:
const Slot *slots_;
int64_t total_slots_;
@@ -422,17 +439,34 @@ class Set {
return *this;
}
+ Iterator operator++(int) const
+ {
+ Iterator copied_iterator = *this;
+ ++copied_iterator;
+ return copied_iterator;
+ }
+
const Key &operator*() const
{
return *slots_[current_slot_].key();
}
+ const Key *operator->() const
+ {
+ return slots_[current_slot_].key();
+ }
+
friend bool operator!=(const Iterator &a, const Iterator &b)
{
BLI_assert(a.slots_ == b.slots_);
BLI_assert(a.total_slots_ == b.total_slots_);
return a.current_slot_ != b.current_slot_;
}
+
+ friend bool operator==(const Iterator &a, const Iterator &b)
+ {
+ return !(a != b);
+ }
};
Iterator begin() const