OpenTTD
|
Simple vector template class. More...
#include <smallvec_type.hpp>
Public Member Functions | |
SmallVector (const SmallVector &other) | |
Copy constructor. More... | |
template<uint X> | |
SmallVector (const SmallVector< T, X > &other) | |
Generic copy constructor. More... | |
SmallVector & | operator= (const SmallVector &other) |
Assignment. More... | |
template<uint X> | |
SmallVector & | operator= (const SmallVector< T, X > &other) |
Generic assignment. More... | |
template<uint X> | |
void | Assign (const SmallVector< T, X > &other) |
Assign items from other vector. | |
void | Clear () |
Remove all items from the list. | |
void | Reset () |
Remove all items from the list and free allocated memory. | |
void | Compact () |
Compact the list down to the smallest block size boundary. | |
T * | Append (uint to_add=1) |
Append an item and return it. More... | |
void | Resize (uint num_items) |
Set the size of the vector, effectively truncating items from the end or appending uninitialised ones. More... | |
const T * | Find (const T &item) const |
Search for the first occurrence of an item. More... | |
T * | Find (const T &item) |
Search for the first occurrence of an item. More... | |
int | FindIndex (const T &item) const |
Search for the first occurrence of an item. More... | |
bool | Contains (const T &item) const |
Tests whether a item is present in the vector. More... | |
void | Erase (T *item) |
Removes given item from this vector. More... | |
void | ErasePreservingOrder (uint pos, uint count=1) |
Remove items from the vector while preserving the order of other items. More... | |
bool | Include (const T &item) |
Tests whether a item is present in the vector, and appends it to the end if not. More... | |
uint | Length () const |
Get the number of items in the list. More... | |
const T * | Begin () const |
Get the pointer to the first item (const) More... | |
T * | Begin () |
Get the pointer to the first item. More... | |
const T * | End () const |
Get the pointer behind the last valid item (const) More... | |
T * | End () |
Get the pointer behind the last valid item. More... | |
const T * | Get (uint index) const |
Get the pointer to item "number" (const) More... | |
T * | Get (uint index) |
Get the pointer to item "number". More... | |
const T & | operator[] (uint index) const |
Get item "number" (const) More... | |
T & | operator[] (uint index) |
Get item "number". More... | |
Protected Attributes | |
T * | data |
The pointer to the first item. | |
uint | items |
The number of items stored. | |
uint | capacity |
The available space for storing items. | |
Simple vector template class.
T | The type of the items stored |
S | The steps of allocation |
Definition at line 29 of file smallvec_type.hpp.
|
inline |
Copy constructor.
other | The other vector to copy. |
Definition at line 42 of file smallvec_type.hpp.
|
inline |
Generic copy constructor.
other | The other vector to copy. |
Definition at line 52 of file smallvec_type.hpp.
|
inline |
Append an item and return it.
to_add | the number of items to append |
Definition at line 134 of file smallvec_type.hpp.
Referenced by NetworkClientListPopupWindow::AddAction(), LanguageScanner::AddFile(), Hotkey::AddKeycode(), AddNearbyStation(), LinkGraph::AddNode(), AddStringForMapping(), AllocateSound(), AlterVehicleListOrder(), SmallVector< SmallPair< uint32, SmallPair< size_t, const void *> >, 16 >::Assign(), BaseVehicleListWindow::BuildActionDropdownList(), BuildAirportWindow::BuildAirportClassDropDown(), NetworkContentListWindow::BuildContentList(), BuildDepotVehicleList(), StoryBookWindow::BuildDropDownList(), NetworkGameWindow::BuildGUINetworkGameList(), RefitWindow::BuildRefitList(), CmdConvertRail(), CmdSetTimetableStart(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), ClientNetworkContentSocketHandler::DownloadContentInfo(), ClientNetworkContentSocketHandler::DownloadSelectedContent(), GetBindAddresses(), GetCargoSummaryOfArticulatedVehicle(), Layouter::GetFont(), GRFConfig::GRFConfig(), HandleParameterInfo(), IniLoadSettingList(), InitNewGRFFile(), Window::InvalidateData(), TextfileWindow::LoadTextfile(), MakeTrainBackup(), NetworkFindBroadcastIPsInternal(), NetworkServerKickOrBanIP(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), FallbackParagraphLayout::NextLine(), ReplaceVehicleWindow::OnClick(), PoolBase::PoolBase(), PopupMainCompanyToolbMenu(), PopupMainToolbMenu(), ClientNetworkContentSocketHandler::Receive_SERVER_INFO(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), ShowMissingContentWindow(), NewGRFWindow::TagNameFilter(), TCPConnecter::TCPConnecter(), ToolbarOptionsClick(), WindowDesc::WindowDesc(), TranslationWriter::Write(), MemoryDumper::WriteByte(), and StringNameWriter::WriteStringID().
|
inline |
Get the pointer to the first item (const)
Definition at line 272 of file smallvec_type.hpp.
Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), AddCargoDelivery(), AfterLoadGRFs(), SmallVector< SmallPair< uint32, SmallPair< size_t, const void *> >, 16 >::Assign(), ClientNetworkContentSocketHandler::Begin(), StoryBookWindow::BuildDropDownList(), TCPConnecter::CheckCallbacks(), ClientNetworkContentSocketHandler::CheckDependencyState(), PoolBase::Clean(), LoadCheckData::Clear(), ClientNetworkContentSocketHandler::Clear(), NetworkUDPSocketHandler::Close(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::CloseListeners(), CmdConvertRail(), CmdSetTimetableStart(), ClientNetworkContentSocketHandler::DownloadSelectedContent(), ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(), ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(), NetworkClientListPopupWindow::DrawWidget(), EngList_Sort(), NetworkContentListWindow::FilterContentList(), FinaliseAirportsArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), GRFConfig::FinalizeParameterInfo(), FindClearedObject(), FindScenario(), GetBindAddresses(), ClientNetworkContentSocketHandler::GetContent(), StoryBookWindow::GetContentHeight(), BaseSet< GraphicsSet, MAX_GFT, true >::GetDescription(), GetFileByFilename(), GetFileByGRFID(), GetLanguage(), LanguageMap::GetMapping(), LanguageMap::GetReverseMapping(), StoryBookWindow::GetSelPageNum(), GetUnitNumberDigits(), NetworkHTTPSocketHandler::HTTPReceive(), IniSaveSettingList(), TCPConnecter::KillAll(), NetworkUDPSocketHandler::Listen(), WindowDesc::LoadFromConfig(), MoveWaypointsToBaseStations(), NetworkFindBroadcastIPs(), NetworkServerKickOrBanIP(), NetworkUDPBroadCast(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), FallbackParagraphLayout::NextLine(), ClientNetworkContentSocketHandler::OnConnect(), ClientNetworkContentSocketHandler::OnDisconnect(), ClientNetworkContentSocketHandler::OnDownloadComplete(), ClientNetworkContentSocketHandler::OnDownloadProgress(), NetworkContentListWindow::OnInvalidateData(), ClientNetworkContentSocketHandler::OnReceiveContentInfo(), Window::ProcessScheduledInvalidations(), ClientNetworkContentSocketHandler::Receive_SERVER_INFO(), NetworkUDPSocketHandler::ReceivePackets(), RegisterGameTranslation(), PacketReader::Reset(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), ResetNewGRF(), RestoreTrainBackup(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), WindowDesc::SaveToConfig(), ClientNetworkContentSocketHandler::SelectAll(), ClientNetworkContentSocketHandler::SelectUpgrade(), NetworkUDPSocketHandler::SendPacket(), NetworkContentListWindow::SortContentList(), ClientNetworkContentSocketHandler::UnselectAll(), GameOptionsWindow::UpdateWidgetSize(), NetworkClientListPopupWindow::UpdateWidgetSize(), ViewportDrawBoundingBoxes(), ViewportSortParentSprites(), BaseSet< GraphicsSet, MAX_GFT, true >::~BaseSet(), ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler(), FreeTypeFontCache::~FreeTypeFontCache(), and NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow().
|
inline |
Get the pointer to the first item.
Definition at line 282 of file smallvec_type.hpp.
|
inline |
Tests whether a item is present in the vector.
The '!=' operator of T is used for comparison.
item | Item to test for |
Definition at line 213 of file smallvec_type.hpp.
Referenced by RefitWindow::BuildRefitList(), ClientNetworkContentSocketHandler::DownloadContentInfo(), BuildVehicleWindow::FilterEngineList(), FindIndustryToDeliver(), GetBestFittingSubType(), GetRailTypeByLabel(), and NetworkFindBroadcastIPsInternal().
|
inline |
Get the pointer behind the last valid item (const)
Definition at line 292 of file smallvec_type.hpp.
Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), AddCargoDelivery(), AfterLoadGRFs(), StoryBookWindow::BuildDropDownList(), ChangeGRFParamValueNames(), TCPConnecter::CheckCallbacks(), ClientNetworkContentSocketHandler::CheckDependencyState(), PoolBase::Clean(), LoadCheckData::Clear(), ClientNetworkContentSocketHandler::Clear(), NetworkUDPSocketHandler::Close(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::CloseListeners(), CmdConvertRail(), CmdSetTimetableStart(), ClientNetworkContentSocketHandler::DownloadSelectedContent(), ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(), NetworkClientListPopupWindow::DrawWidget(), ClientNetworkContentSocketHandler::End(), NetworkContentListWindow::FilterContentList(), FinaliseAirportsArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), GRFConfig::FinalizeParameterInfo(), FindClearedObject(), FindScenario(), ReplaceVehicleWindow::GenerateLists(), GetBindAddresses(), GetCargoSummaryOfArticulatedVehicle(), ClientNetworkContentSocketHandler::GetContent(), StoryBookWindow::GetContentHeight(), BaseSet< GraphicsSet, MAX_GFT, true >::GetDescription(), GetFileByFilename(), GetFileByGRFID(), FreeTypeFontCache::GetFontTable(), GetLanguage(), LanguageMap::GetMapping(), LanguageMap::GetReverseMapping(), StoryBookWindow::GetSelPageNum(), GetUnitNumberDigits(), NetworkHTTPSocketHandler::HTTPReceive(), IniSaveSettingList(), TCPConnecter::KillAll(), NetworkUDPSocketHandler::Listen(), WindowDesc::LoadFromConfig(), MoveWaypointsToBaseStations(), NetworkFindBroadcastIPs(), NetworkServerKickOrBanIP(), NetworkUDPBroadCast(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), ClientNetworkContentSocketHandler::OnConnect(), ClientNetworkContentSocketHandler::OnDisconnect(), ClientNetworkContentSocketHandler::OnDownloadComplete(), ClientNetworkContentSocketHandler::OnDownloadProgress(), NetworkContentListWindow::OnInvalidateData(), ClientNetworkContentSocketHandler::OnReceiveContentInfo(), Window::ProcessScheduledInvalidations(), ClientNetworkContentSocketHandler::Receive_SERVER_INFO(), NetworkUDPSocketHandler::ReceivePackets(), RegisterGameTranslation(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), Layouter::ResetFontCache(), ResetNewGRF(), RestoreTrainBackup(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), WindowDesc::SaveToConfig(), ClientNetworkContentSocketHandler::SelectAll(), ClientNetworkContentSocketHandler::SelectUpgrade(), NetworkUDPSocketHandler::SendPacket(), NetworkContentListWindow::SortContentList(), ClientNetworkContentSocketHandler::UnselectAll(), GameOptionsWindow::UpdateWidgetSize(), NetworkClientListPopupWindow::UpdateWidgetSize(), ViewportDrawBoundingBoxes(), ViewportSortParentSprites(), BaseSet< GraphicsSet, MAX_GFT, true >::~BaseSet(), ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler(), FreeTypeFontCache::~FreeTypeFontCache(), and NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow().
|
inline |
Get the pointer behind the last valid item.
Definition at line 302 of file smallvec_type.hpp.
|
inline |
Removes given item from this vector.
item | item to remove |
Definition at line 223 of file smallvec_type.hpp.
Referenced by Hotkey::AddKeycode(), AddNearbyStation(), TCPConnecter::CheckCallbacks(), NetworkHTTPSocketHandler::HTTPReceive(), ClientNetworkContentSocketHandler::RemoveCallback(), WindowDesc::WindowDesc(), and PoolBase::~PoolBase().
|
inline |
Remove items from the vector while preserving the order of other items.
pos | First item to remove. |
count | Number of consecutive items to remove. |
Definition at line 234 of file smallvec_type.hpp.
Referenced by RefitWindow::BuildRefitList().
|
inline |
Search for the first occurrence of an item.
The '!=' operator of T is used for comparison.
item | Item to search for |
Definition at line 167 of file smallvec_type.hpp.
Referenced by Hotkey::AddKeycode(), GetCargoSummaryOfArticulatedVehicle(), ClientNetworkContentSocketHandler::RemoveCallback(), WindowDesc::WindowDesc(), and PoolBase::~PoolBase().
|
inline |
Search for the first occurrence of an item.
The '!=' operator of T is used for comparison.
item | Item to search for |
Definition at line 181 of file smallvec_type.hpp.
|
inline |
Search for the first occurrence of an item.
The '!=' operator of T is used for comparison.
item | Item to search for |
Definition at line 195 of file smallvec_type.hpp.
Referenced by BuildCargoTranslationMap(), CmdSetTimetableStart(), GetReverseRailTypeTranslation(), and NewGRFWindow::TagNameFilter().
|
inline |
Get the pointer to item "number" (const)
index | the position of the item |
Definition at line 313 of file smallvec_type.hpp.
Referenced by AddNearbyStation(), BuildBridgeWindow::BridgeSpeedSorter(), ClientNetworkContentSocketHandler::Get(), GRFParameterInfo::GRFParameterInfo(), BuildBridgeWindow::UpdateWidgetSize(), and GRFParameterInfo::~GRFParameterInfo().
|
inline |
Get the pointer to item "number".
index | the position of the item |
Definition at line 326 of file smallvec_type.hpp.
|
inline |
Tests whether a item is present in the vector, and appends it to the end if not.
The '!=' operator of T is used for comparison.
item | Item to test for |
Definition at line 250 of file smallvec_type.hpp.
Referenced by ClientNetworkContentSocketHandler::AddCallback(), Hotkey::AddKeycode(), RefitWindow::BuildRefitList(), DeliverGoodsToIndustry(), GetBestFittingSubType(), NetworkContentDownloadStatusWindow::OnDownloadProgress(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), and UpdateTrainPowerProc().
|
inline |
Get the number of items in the list.
Definition at line 262 of file smallvec_type.hpp.
Referenced by NewGRFWindow::AddGRFToActive(), AddNearbyStation(), SmallVector< SmallPair< uint32, SmallPair< size_t, const void *> >, 16 >::Assign(), BuildCargoTranslationMap(), NetworkContentListWindow::BuildContentList(), StoryBookWindow::BuildDropDownList(), NetworkGameWindow::BuildGUINetworkGameList(), RefitWindow::BuildRefitList(), IndustryCargoesWindow::CalculatePositionInWidget(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdMassStartStopVehicle(), CmdSetTimetableStart(), DeliverGoodsToIndustry(), ClientNetworkContentSocketHandler::DownloadSelectedContent(), ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(), ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(), NewGRFParametersWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildVehicleWindow::DrawWidget(), EngList_Sort(), BuildVehicleWindow::FilterEngineList(), GetBestFittingSubType(), GetBindAddresses(), GetCargoTranslation(), TextfileWindow::GetContentHeight(), GetGameStringPtr(), GetLinkGraphJobDesc(), RefitWindow::GetRefitOption(), GetReverseRailTypeTranslation(), MemoryDumper::GetSize(), StringFilter::GetState(), GetTrainDetailsWndVScroll(), GetUnitNumberDigits(), GRFConfig::GRFConfig(), GRFParameterInfo::GRFParameterInfo(), HandleParameterInfo(), NetworkHTTPSocketHandler::HTTPReceive(), StringFilter::IsEmpty(), IsGoodGRFConfigList(), ClientNetworkContentSocketHandler::Length(), NetworkUDPSocketHandler::Listen(), NeedRailTypeConversion(), TextfileWindow::NextString(), BuildBridgeWindow::OnClick(), CompanyStationsWindow::OnClick(), StoryBookWindow::OnClick(), TownDirectoryWindow::OnClick(), BuildVehicleWindow::OnClick(), IndustryDirectoryWindow::OnClick(), VehicleListWindow::OnClick(), SavePresetWindow::OnClick(), RefitWindow::OnInit(), StoryBookWindow::OnInvalidateData(), SpriteAlignerWindow::OnInvalidateData(), SelectStationWindow< T >::OnInvalidateData(), BuildBridgeWindow::OnKeyPress(), VehicleGroupWindow::OnMouseDrag(), VehicleGroupWindow::OnPaint(), BuildVehicleWindow::OnPaint(), VehicleListWindow::OnPaint(), NewGRFWindow::OnQueryTextFinished(), RefitWindow::RefreshScrollbar(), RestoreTrainBackup(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), SaveKeycodes(), SavePresetWindow::SavePresetWindow(), WindowDesc::SaveToConfig(), SendAllVehiclesToDepot(), NetworkUDPSocketHandler::SendPacket(), IcuStringIterator::SetCurPosition(), GRFConfig::SetParameterDefaults(), RefitWindow::SetSelection(), TextfileWindow::SetupScrollbars(), ShowMissingContentWindow(), LinkGraph::Size(), BuildBridgeWindow::SortBridgeList(), NewGRFWindow::TagNameFilter(), StoryBookWindow::UpdatePrevNextDisabledState(), BuildBridgeWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), NetworkClientListPopupWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), WhoCanServiceIndustry(), StringNameWriter::WriteStringID(), GRFConfig::~GRFConfig(), GRFParameterInfo::~GRFParameterInfo(), and PoolBase::~PoolBase().
|
inline |
Assignment.
other | The other vector to assign. |
Definition at line 61 of file smallvec_type.hpp.
|
inline |
Generic assignment.
other | The other vector to assign. |
Definition at line 72 of file smallvec_type.hpp.
|
inline |
Get item "number" (const)
index | the position of the item |
Definition at line 339 of file smallvec_type.hpp.
|
inline |
Get item "number".
index | the position of the item |
Definition at line 351 of file smallvec_type.hpp.
|
inline |
Set the size of the vector, effectively truncating items from the end or appending uninitialised ones.
num_items | Target size. |
Definition at line 151 of file smallvec_type.hpp.
Referenced by RefitWindow::BuildRefitList(), and LinkGraphJob::Init().