OpenTTD Source: src/core/smallvec_type.hpp File Reference

OpenTTD Source 1.11.0-RC1

Functions
smallvec_type.hpp File Reference
`#include "alloc_func.hpp"`
`#include "mem_func.hpp"`
`#include <vector>`

Go to the source code of this file.

## Functions
template<typename T >
bool | include (std::vector< T > &vec, const T &item)
| Helper function to append an item to a vector if it is not already contained Consider using std::set, std::unordered_set or std::flat_set in new code. More...
template<typename T >
int | find_index (std::vector< T > const &vec, T const &item)
| Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_set in new code. More...

## Detailed Description

Simple vector class that allows allocating an item without the need to copy this->data needlessly.

Definition in file smallvec_type.hpp.

## Function Documentation

## ◆ find_index()

template<typename T >

int find_index | ( | std::vector< T > const & | vec,
|  | T const & | item
| ) |  |

Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_set in new code.

Parameters

  vec | A reference to the vector to be extended
  item | Reference to the item to be search for

Returns
  Index of element if found, otherwise -1

Definition at line 44 of file smallvec_type.hpp.

Referenced by NetworkContentListWindow::FilterContentList(), GetReverseRailTypeTranslation(), VehicleGroupWindow::SelectGroup(), and NetworkContentListWindow::SortContentList().

## ◆ include()

template<typename T >

bool include | ( | std::vector< T > & | vec,
|  | const T & | item
| ) |  |
| inline

Helper function to append an item to a vector if it is not already contained Consider using std::set, std::unordered_set or std::flat_set in new code.

Parameters

  vec | A reference to the vector to be extended
  item | Reference to the item to be copy-constructed if not found

Returns
  Whether the item was already present

Definition at line 27 of file smallvec_type.hpp.

Referenced by AddAnimatedTile(), ClientNetworkContentSocketHandler::AddCallback(), ScenarioScanner::AddFile(), Hotkey::AddKeycode(), RefitWindow::BuildRefitList(), CheckSubsidised(), DeliverGoodsToIndustry(), GetBestFittingSubType(), GetVehicleSet(), NetworkContentDownloadStatusWindow::OnDownloadProgress(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), UpdateRoadVehPowerProc(), and UpdateTrainPowerProc().