|
OpenTTD Source 20251116-master-g21329071df
|
Some simple functions to help with accessing containers. More...
Go to the source code of this file.
Functions | |
| template<typename Container > | |
| bool | include (Container &container, typename Container::const_reference &item) |
| Helper function to append an item to a container if it is not already contained. | |
| template<typename Container > | |
| int | find_index (Container const &container, typename Container::const_reference item) |
| Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_set in new code. | |
| template<typename TIter > | |
| auto | Slide (TIter first, TIter last, TIter position) -> std::pair< TIter, TIter > |
| Move elements between first and last to a new position, rotating elements in between as necessary. | |
Some simple functions to help with accessing containers.
Definition in file container_func.hpp.
| int find_index | ( | Container const & | container, |
| typename Container::const_reference | item | ||
| ) |
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_set in new code.
| container | A reference to the container to be searched. |
| item | Reference to the item to be search for |
Definition at line 41 of file container_func.hpp.
Referenced by BuildCargoTranslationMap(), NetworkContentListWindow::FilterContentList(), GetReverseRailTypeTranslation(), GetReverseRoadTypeTranslation(), and NetworkContentListWindow::SortContentList().
|
inline |
Helper function to append an item to a container if it is not already contained.
The container must have a emplace_back function. Consider using std::set, std::unordered_set or std::flat_set in new code.
| container | A reference to the container to be extended |
| item | Reference to the item to be copy-constructed if not found |
Definition at line 24 of file container_func.hpp.
Referenced by ClientNetworkContentSocketHandler::AddCallback(), ScenarioScanner::AddFile(), RefitWindow::BuildRefitList(), CheckSubsidised(), CmdConvertRail(), CmdConvertRoad(), DeliverGoodsToIndustry(), GetBestFittingSubType(), GetVehicleSet(), RoadStop::Entry::Rebuild(), RemoveFromRailBaseStation(), and ClientNetworkContentSocketHandler::ReverseLookupTreeDependency().
| auto Slide | ( | TIter | first, |
| TIter | last, | ||
| TIter | position | ||
| ) | -> std::pair<TIter, TIter> |
Move elements between first and last to a new position, rotating elements in between as necessary.
| first | Iterator to first element to move. |
| last | Iterator to (end-of) last element to move. |
| position | Iterator to where range should be moved to. |
Definition at line 57 of file container_func.hpp.
Referenced by CommitVehicleListOrderChanges(), NewGRFWindow::OnDragDrop(), and EngineOverrideManager::UseUnreservedID().