MCPcopy Create free account
hub / github.com/apache/fory / Iterator

Class Iterator

cpp/fory/util/flat_int_map.h:88–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 };
87
88 class Iterator {
89 public:
90 Iterator(Entry *entries, size_t capacity, size_t index)
91 : entries_(entries), capacity_(capacity), index_(index) {
92 while (index_ < capacity_ && entries_[index_].key == k_empty)
93 ++index_;
94 }
95 std::pair<K, V> operator*() const {
96 return {entries_[index_].key, entries_[index_].value};
97 }
98 const Entry *operator->() const { return &entries_[index_]; }
99 Iterator &operator++() {
100 ++index_;
101 while (index_ < capacity_ && entries_[index_].key == k_empty)
102 ++index_;
103 return *this;
104 }
105 bool operator==(const Iterator &other) const {
106 return index_ == other.index_;
107 }
108 bool operator!=(const Iterator &other) const { return !(*this == other); }
109
110 private:
111 Entry *entries_;
112 size_t capacity_;
113 size_t index_;
114 };
115
116 explicit FlatIntMap(size_t initial_capacity = 64,
117 float load_factor = k_default_load_factor)

Callers 2

beginMethod · 0.85
endMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected