summaryrefslogtreecommitdiff
path: root/src/core/smallmap_type.hpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-02-17 11:20:52 +0000
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commitab711e6942757d775c08c31a6c32d488feba1dba (patch)
treed102dc6d0e6b9c33e7205b63e3360ebd720a3ebb /src/core/smallmap_type.hpp
parent297fd3dda3abe353ebe2fe77c67b011e24d403bc (diff)
downloadopenttd-ab711e6942757d775c08c31a6c32d488feba1dba.tar.xz
Codechange: Replaced SmallVector::[Begin|End]() with std alternatives
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r--src/core/smallmap_type.hpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp
index 0917c5423..8cc96302f 100644
--- a/src/core/smallmap_type.hpp
+++ b/src/core/smallmap_type.hpp
@@ -55,12 +55,13 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
* @param key key to find
* @return &Pair(key, data) if found, this->End() if not
*/
- inline const Pair *Find(const T &key) const
+ inline typename std::vector<Pair>::const_iterator Find(const T &key) const
{
- for (uint i = 0; i < std::vector<Pair>::size(); i++) {
- if (key == std::vector<Pair>::operator[](i).first) return &std::vector<Pair>::operator[](i);
+ typename std::vector<Pair>::const_iterator it;
+ for (it = std::vector<Pair>::begin(); it != std::vector<Pair>::end(); it++) {
+ if (key == it->first) return it;
}
- return this->End();
+ return it;
}
/**
@@ -114,7 +115,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
*/
inline void Erase(Pair *pair)
{
- assert(pair >= this->Begin() && pair < this->End());
+ assert(pair >= std::vector<Pair>::data() && pair < this->End());
auto distance = pair - std::vector<Pair>::data();
std::vector<Pair>::erase(std::vector<Pair>::begin() + distance);
}
@@ -166,7 +167,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
inline void SortByKey()
{
- QSortT(this->Begin(), std::vector<Pair>::size(), KeySorter);
+ QSortT(std::vector<Pair>::data(), std::vector<Pair>::size(), KeySorter);
}
static int CDECL KeySorter(const Pair *a, const Pair *b)