File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class SequentialMap {
77public:
88 struct PairT {
99 KeyT key;
10- ValT element ;
10+ ValT second ;
1111 };
1212
1313 using DataT = FixedVector<PairT, N>;
@@ -16,23 +16,23 @@ public:
1616 const ValT &operator [](const KeyT key) const {
1717 for (auto &pair : data) {
1818 if (pair.key == key)
19- return pair.element ;
19+ return pair.second ;
2020 }
2121 return ValT{};
2222 }
2323
2424 ValT &operator [](const KeyT key) {
2525 for (auto &pair : data) {
2626 if (pair.key == key)
27- return pair.element ;
27+ return pair.second ;
2828 }
2929
3030 auto newsize = data.push_back_for_overwrite ();
3131 if (newsize == data.max_size ()) {
3232 // Overflow: silently return last element
3333 newsize--;
3434 }
35- return data[newsize].element ;
35+ return data[newsize].second ;
3636 }
3737
3838 void clear () {
@@ -43,7 +43,15 @@ public:
4343 return data.size () == data.max_size ();
4444 }
4545
46- bool exists (const KeyT key) {
46+ auto find (KeyT key) {
47+ for (auto it = data.begin (); it < data.end (); it++) {
48+ if (it->key == key)
49+ return it;
50+ }
51+ return data.end ();
52+ }
53+
54+ bool exists (const KeyT key) const {
4755 for (auto &pair : data) {
4856 if (pair.key == key)
4957 return true ;
You can’t perform that action at this time.
0 commit comments