Commit ef71d453 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Some ContiguousMap additions/fixes

parent d78db72a
...@@ -43,12 +43,11 @@ public: ...@@ -43,12 +43,11 @@ public:
const_iterator begin() const noexcept { return map.begin(); } const_iterator begin() const noexcept { return map.begin(); }
const_iterator end() const noexcept { return map.end(); } const_iterator end() const noexcept { return map.end(); }
iterator erase(const_iterator position) { void erase(const_iterator position) {
int idx = map[position->first]; int idx = map[position->first];
free_list.push_back(idx); free_list.push_back(idx);
vec[idx] = TVal(); vec[idx] = TVal();
map.erase(position->first); map.erase(position->first);
return begin(); // this is broken...
} }
size_type erase(const TKey& key) { size_type erase(const TKey& key) {
...@@ -73,9 +72,9 @@ public: ...@@ -73,9 +72,9 @@ public:
free_list.pop_back(); free_list.pop_back();
} else { } else {
idx = vec.size(); idx = vec.size();
vec.push_back(TVal());
} }
map[key] = idx; map[key] = idx;
vec.push_back(TVal());
return vec[idx]; return vec[idx];
} else { } else {
return vec[it->second]; return vec[it->second];
...@@ -91,9 +90,9 @@ public: ...@@ -91,9 +90,9 @@ public:
free_list.pop_back(); free_list.pop_back();
} else { } else {
idx = vec.size(); idx = vec.size();
vec.push_back(TVal());
} }
map[key] = idx; map[key] = idx;
vec.push_back(TVal());
return vec[idx]; return vec[idx];
} else { } else {
return vec[it->second]; return vec[it->second];
...@@ -102,7 +101,8 @@ public: ...@@ -102,7 +101,8 @@ public:
TVal getMapped(int idx) const { return vec[idx]; } TVal getMapped(int idx) const { return vec[idx]; }
size_type size() const { return vec.size(); } size_type size() const { return map.size(); }
bool empty() const { return map.empty(); }
const vec_type& vector() { return vec; } const vec_type& vector() { return vec; }
}; };
} }
......
...@@ -374,7 +374,7 @@ public: ...@@ -374,7 +374,7 @@ public:
// in the attr_offssets map. // in the attr_offssets map.
// Also, if we have any children, we can skip scanning our attr_offsets map, since it will be a subset // Also, if we have any children, we can skip scanning our attr_offsets map, since it will be a subset
// of our child's map. // of our child's map.
if (!children.size()) if (children.empty())
for (auto p : attr_offsets) for (auto p : attr_offsets)
visitor->visit(p.first); visitor->visit(p.first);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment