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_map.hh')
-rw-r--r--source/blender/blenlib/BLI_map.hh38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh
index 9480af89107..9fa69853e44 100644
--- a/source/blender/blenlib/BLI_map.hh
+++ b/source/blender/blenlib/BLI_map.hh
@@ -120,6 +120,9 @@ template<
*/
typename Allocator = GuardedAllocator>
class Map {
+ public:
+ using size_type = int64_t;
+
private:
/**
* Slots are either empty, occupied or removed. The number of occupied slots can be computed by
@@ -623,6 +626,9 @@ class Map {
* This uses the "curiously recurring template pattern" (CRTP).
*/
template<typename SubIterator> struct BaseIterator {
+ using iterator_category = std::forward_iterator_tag;
+ using difference_type = std::ptrdiff_t;
+
Slot *slots_;
int64_t total_slots_;
int64_t current_slot_;
@@ -642,6 +648,13 @@ class Map {
return *this;
}
+ BaseIterator operator++(int) const
+ {
+ BaseIterator copied_iterator = *this;
+ ++copied_iterator;
+ return copied_iterator;
+ }
+
friend bool operator!=(const BaseIterator &a, const BaseIterator &b)
{
BLI_assert(a.slots_ == b.slots_);
@@ -649,6 +662,11 @@ class Map {
return a.current_slot_ != b.current_slot_;
}
+ friend bool operator==(const BaseIterator &a, const BaseIterator &b)
+ {
+ return !(a != b);
+ }
+
SubIterator begin() const
{
for (int64_t i = 0; i < total_slots_; i++) {
@@ -672,6 +690,10 @@ class Map {
class KeyIterator final : public BaseIterator<KeyIterator> {
public:
+ using value_type = Key;
+ using pointer = const Key *;
+ using reference = const Key &;
+
KeyIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<KeyIterator>(slots, total_slots, current_slot)
{
@@ -685,6 +707,10 @@ class Map {
class ValueIterator final : public BaseIterator<ValueIterator> {
public:
+ using value_type = Value;
+ using pointer = const Value *;
+ using reference = const Value &;
+
ValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<ValueIterator>(slots, total_slots, current_slot)
{
@@ -698,6 +724,10 @@ class Map {
class MutableValueIterator final : public BaseIterator<MutableValueIterator> {
public:
+ using value_type = Value;
+ using pointer = Value *;
+ using reference = Value &;
+
MutableValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<MutableValueIterator>(slots, total_slots, current_slot)
{
@@ -726,6 +756,10 @@ class Map {
class ItemIterator final : public BaseIterator<ItemIterator> {
public:
+ using value_type = Item;
+ using pointer = Item *;
+ using reference = Item &;
+
ItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<ItemIterator>(slots, total_slots, current_slot)
{
@@ -740,6 +774,10 @@ class Map {
class MutableItemIterator final : public BaseIterator<MutableItemIterator> {
public:
+ using value_type = MutableItem;
+ using pointer = MutableItem *;
+ using reference = MutableItem &;
+
MutableItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<MutableItemIterator>(slots, total_slots, current_slot)
{