MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / iterator

Class iterator

tensorflow/core/lib/gtl/flatmap.h:120–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 key_equal key_eq() const { return rep_.key_eq(); }
119
120 class iterator {
121 public:
122 typedef typename FlatMap::difference_type difference_type;
123 typedef typename FlatMap::value_type value_type;
124 typedef typename FlatMap::pointer pointer;
125 typedef typename FlatMap::reference reference;
126 typedef ::std::forward_iterator_tag iterator_category;
127
128 iterator() : b_(nullptr), end_(nullptr), i_(0) {}
129
130 // Make iterator pointing at first element at or after b.
131 iterator(Bucket* b, Bucket* end) : b_(b), end_(end), i_(0) { SkipUnused(); }
132
133 // Make iterator pointing exactly at ith element in b, which must exist.
134 iterator(Bucket* b, Bucket* end, uint32 i) : b_(b), end_(end), i_(i) {
135 FillValue();
136 }
137
138 reference operator*() { return *val(); }
139 pointer operator->() { return val(); }
140 bool operator==(const iterator& x) const {
141 return b_ == x.b_ && i_ == x.i_;
142 }
143 bool operator!=(const iterator& x) const { return !(*this == x); }
144 iterator& operator++() {
145 DCHECK(b_ != end_);
146 i_++;
147 SkipUnused();
148 return *this;
149 }
150 iterator operator++(int /*indicates postfix*/) {
151 iterator tmp(*this);
152 ++*this;
153 return tmp;
154 }
155
156 private:
157 friend class FlatMap;
158 Bucket* b_;
159 Bucket* end_;
160 char space_ alignas(value_type)[sizeof(value_type)];
161 uint32 i_;
162
163 pointer val() { return reinterpret_cast<pointer>(space_); }
164 void FillValue() { new (space_) value_type(b_->key(i_), b_->val(i_)); }
165 void SkipUnused() {
166 while (b_ < end_) {
167 if (i_ >= Rep::kWidth) {
168 i_ = 0;
169 b_++;
170 } else if (b_->marker[i_] < 2) {
171 i_++;
172 } else {
173 FillValue();
174 break;
175 }
176 }
177 }

Callers 9

beginMethod · 0.70
endMethod · 0.70
findMethod · 0.70
InsertMethod · 0.70
beginMethod · 0.70
endMethod · 0.70
findMethod · 0.70
emplaceMethod · 0.70
InsertMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected