Fixed not being to iterate over const collections.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-22 18:15:13 +01:00
parent c1167e704a
commit 79ab962e2f
3 changed files with 17 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ namespace Arbutils::Collections {
std::unordered_map<KeyT, ValueT> _map;
using iterator = typename std::unordered_map<KeyT, ValueT>::iterator;
using const_iterator = typename std::unordered_map<KeyT, ValueT>::const_iterator;
public:
Dictionary() : _map() {}
explicit Dictionary(size_t capacity) : _map(capacity) {}
@@ -73,10 +74,10 @@ namespace Arbutils::Collections {
inline const ValueT& operator[](KeyT key) const { return Get(key); }
iterator begin() { return _map.begin(); }
iterator begin() const { return _map.begin(); }
const_iterator begin() const { return _map.begin(); }
iterator end() { return _map.end(); }
iterator end() const { return _map.end(); }
const_iterator end() const { return _map.end(); }
};
}

View File

@@ -10,6 +10,7 @@ namespace Arbutils::Collections {
private:
std::vector<ValueT> _vector;
using iterator = typename std::vector<ValueT>::iterator;
using const_iterator = typename std::vector<ValueT>::const_iterator;
public:
List() : _vector() {}
@@ -40,7 +41,9 @@ namespace Arbutils::Collections {
return _vector.at(index);
}
inline bool Contains(ValueT value) { return std::find(_vector.begin(), _vector.end(), value) != _vector.end(); }
inline bool Contains(ValueT value) const {
return std::find(_vector.begin(), _vector.end(), value) != _vector.end();
}
inline void Append(ValueT value) { _vector.push_back(value); }
@@ -54,10 +57,10 @@ namespace Arbutils::Collections {
inline void Resize(size_t size, ValueT defaultValue) { _vector.resize(size, defaultValue); }
iterator begin() { return _vector.begin(); }
iterator begin() const { return _vector.begin(); }
const_iterator begin() const { return _vector.begin(); }
iterator end() { return _vector.end(); }
iterator end() const { return _vector.end(); }
const_iterator end() const { return _vector.end(); }
const ValueT* RawData() const { return _vector.data(); }
};