mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Replaced SmallVector::Find() non-const with std::find()
This commit is contained in:
parent
f3938fdb83
commit
81315939b9
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,20 +116,6 @@ public:
|
|||
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 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.
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue