diff options
-rw-r--r-- | src/animated_tile.cpp | 2 | ||||
-rw-r--r-- | src/core/pool_func.cpp | 2 | ||||
-rw-r--r-- | src/core/smallvec_type.hpp | 14 | ||||
-rw-r--r-- | src/hotkeys.cpp | 2 | ||||
-rw-r--r-- | src/network/network_content.h | 2 | ||||
-rw-r--r-- | src/train_gui.cpp | 8 | ||||
-rw-r--r-- | src/window.cpp | 2 |
7 files changed, 12 insertions, 20 deletions
diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 5d4384820..3341f5795 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -27,7 +27,7 @@ SmallVector<TileIndex, 256> _animated_tiles; */ void DeleteAnimatedTile(TileIndex tile) { - TileIndex *to_remove = _animated_tiles.Find(tile); + TileIndex *to_remove = &*std::find(_animated_tiles.begin(), _animated_tiles.end(), tile); if (to_remove != _animated_tiles.End()) { /* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */ _animated_tiles.ErasePreservingOrder(to_remove); diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp index 914cbcfd9..97f9ad1c7 100644 --- a/src/core/pool_func.cpp +++ b/src/core/pool_func.cpp @@ -21,7 +21,7 @@ /* virtual */ PoolBase::~PoolBase() { PoolVector *pools = PoolBase::GetPools(); - pools->Erase(pools->Find(this)); + pools->erase(std::find(pools->begin(), pools->end(), this)); if (pools->size() == 0) delete pools; } diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 7e0abec76..289cc9e1d 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -120,20 +120,6 @@ public: * Search for the first occurrence of an item. * The '!=' operator of T is used for comparison. * @param item Item to search for - * @return The position of the item, or End() when not present - */ - inline T *Find(const T &item) - { - T *pos = this->Begin(); - const T *end = this->End(); - while (pos != end && *pos != item) pos++; - return pos; - } - - /** - * Search for the first occurrence of an item. - * The '!=' operator of T is used for comparison. - * @param item Item to search for * @return The position of the item, or -1 when not present */ inline int FindIndex(const T &item) const diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 9411887ea..9f323bc28 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -260,7 +260,7 @@ HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandler HotkeyList::~HotkeyList() { - _hotkey_lists->Erase(_hotkey_lists->Find(this)); + _hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this)); } /** diff --git a/src/network/network_content.h b/src/network/network_content.h index 0d30de857..a81cc6a6d 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -142,7 +142,7 @@ public: /** Add a callback to this class */ void AddCallback(ContentCallback *cb) { this->callbacks.Include(cb); } /** Remove a callback */ - void RemoveCallback(ContentCallback *cb) { this->callbacks.Erase(this->callbacks.Find(cb)); } + void RemoveCallback(ContentCallback *cb) { this->callbacks.erase(std::find(this->callbacks.begin(), this->callbacks.end(), cb)); } }; extern ClientNetworkContentSocketHandler _network_content_client; diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 3c394ef19..eab6a33e3 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -174,6 +174,12 @@ struct CargoSummaryItem { { return this->cargo != other.cargo || this->subtype != other.subtype; } + + /** Used by std::find() and similar functions */ + inline bool operator == (const CargoSummaryItem &other) const + { + return !(this->cargo != other.cargo); + } }; static const uint TRAIN_DETAILS_MIN_INDENT = 32; ///< Minimum indent level in the train details window @@ -272,7 +278,7 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su new_item.subtype = GetCargoSubtypeText(v); if (new_item.cargo == INVALID_CARGO && new_item.subtype == STR_EMPTY) continue; - CargoSummaryItem *item = summary->Find(new_item); + CargoSummaryItem *item = &*std::find(summary->begin(), summary->end(), new_item); if (item == summary->End()) { item = summary->Append(); item->cargo = new_item.cargo; diff --git a/src/window.cpp b/src/window.cpp index c6a9f1653..471ac08a2 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -114,7 +114,7 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi WindowDesc::~WindowDesc() { - _window_descs->Erase(_window_descs->Find(this)); + _window_descs->erase(std::find(_window_descs->begin(), _window_descs->end(), this)); } /** |