SmallVector< T, S > Class Template Reference

Simple vector template class. More...

#include <smallvec_type.hpp>

Inheritance diagram for SmallVector< T, S >:
AutoFreeSmallVector< T, S >

Public Member Functions

template<uint X>
 SmallVector (const SmallVector< T, X > &other)
template<uint X>
SmallVectoroperator= (const SmallVector< T, X > &other)
FORCEINLINE void Clear ()
 Remove all items from the list.
FORCEINLINE void Reset ()
 Remove all items from the list and free allocated memory.
FORCEINLINE void Compact ()
 Compact the list down to the smallest block size boundary.
FORCEINLINE T * Append (uint to_add=1)
 Append an item and return it.
FORCEINLINE const T * Find (const T &item) const
 Search for the first occurrence of an item.
FORCEINLINE T * Find (const T &item)
 Search for the first occurrence of an item.
FORCEINLINE int FindIndex (const T &item)
 Search for the first occurrence of an item.
FORCEINLINE bool Contains (const T &item) const
 Tests whether a item is present in the vector.
FORCEINLINE void Erase (T *item)
 Removes given item from this vector.
FORCEINLINE bool Include (const T &item)
 Tests whether a item is present in the vector, and appends it to the end if not.
FORCEINLINE uint Length () const
 Get the number of items in the list.
FORCEINLINE const T * Begin () const
 Get the pointer to the first item (const).
FORCEINLINE T * Begin ()
 Get the pointer to the first item.
FORCEINLINE const T * End () const
 Get the pointer behind the last valid item (const).
FORCEINLINE T * End ()
 Get the pointer behind the last valid item.
FORCEINLINE const T * Get (uint index) const
 Get the pointer to item "number" (const).
FORCEINLINE T * Get (uint index)
 Get the pointer to item "number".
FORCEINLINE const T & operator[] (uint index) const
 Get item "number" (const).
FORCEINLINE T & operator[] (uint index)
 Get item "number".

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.

Detailed Description

template<typename T, uint S>
class SmallVector< T, S >

Simple vector template class.

Note:
There are no asserts in the class so you have to care about that you grab an item which is inside the list.
Template Parameters:
T The type of the items stored
S The steps of allocation

Definition at line 30 of file smallvec_type.hpp.


Member Function Documentation

template<typename T, uint S>
FORCEINLINE T* SmallVector< T, S >::Append ( uint  to_add = 1  )  [inline]

Append an item and return it.

Parameters:
to_add the number of items to append
Returns:
pointer to newly allocated item

Definition at line 97 of file smallvec_type.hpp.

Referenced by NetworkClientListPopupWindow::AddAction(), AddChildSpriteScreen(), FiosFileScanner::AddFile(), AddNearbyStation(), PacketReader::AddPacket(), AddSortableSpriteToDraw(), AddTileSpriteToDraw(), CompanyLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), BuildDepotVehicleList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildNetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), CheckFlatLandRailStation(), CmdBuildRailStation(), CmdConvertRail(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), ClientNetworkContentSocketHandler::DownloadContentInfo(), DrawString(), FindIndustryToDeliver(), FindStationsNearby(), FiosGetFileList(), ReplaceVehicleWindow::GenerateReplaceVehList(), GenerateVehicleSortList(), GetBindAddresses(), GetCargoSummaryOfArticulatedVehicle(), GetGRFPresetList(), GetLanguageList(), GetNewEngine(), GRFConfig::GRFConfig(), HandleParameterInfo(), SmallVector< RefitOption, 32 >::Include(), IniLoadSettingList(), MakeTrainBackup(), NetworkFindBroadcastIPsInternal(), NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), NewGRFWindow::OnClick(), ClientNetworkContentSocketHandler::OnReceiveData(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), ShowBuildBridgeWindow(), TCPConnecter::TCPConnecter(), and MemoryDumper::WriteByte().

template<typename T, uint S>
FORCEINLINE T* SmallVector< T, S >::Begin (  )  [inline]

Get the pointer to the first item.

Returns:
the pointer to the first item

Definition at line 214 of file smallvec_type.hpp.

template<typename T, uint S>
FORCEINLINE const T* SmallVector< T, S >::Begin (  )  const [inline]

Get the pointer to the first item (const).

Returns:
the pointer to the first item

Definition at line 204 of file smallvec_type.hpp.

Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), FiosFileScanner::AddFile(), ClientNetworkContentSocketHandler::Begin(), TCPConnecter::CheckCallbacks(), ClientNetworkContentSocketHandler::CheckDependencyState(), CheckSubsidised(), ClientNetworkContentSocketHandler::Clear(), LoadCheckData::Clear(), NetworkUDPSocketHandler::Close(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::CloseListeners(), CmdConvertRail(), CmdRemoveFromRailStation(), NetworkContentListWindow::DrawDetails(), DrawString(), NetworkClientListPopupWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), EngList_Sort(), SmallVector< RefitOption, 32 >::Erase(), NetworkContentListWindow::FilterContentList(), FinaliseAirportsArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), SmallVector< RefitOption, 32 >::Find(), FindClearedObject(), SmallVector< RefitOption, 32 >::FindIndex(), FiosGetFileList(), GetBindAddresses(), ClientNetworkContentSocketHandler::GetContent(), BaseSet< MusicSet, NUM_SONGS_AVAILABLE, GM_DIR >::GetDescription(), GetLanguage(), LanguageMap::GetMapping(), LanguageMap::GetReverseMapping(), HasScenario(), NetworkHTTPSocketHandler::HTTPReceive(), IniSaveSettingList(), InitializeLanguagePacks(), TCPConnecter::KillAll(), NetworkUDPSocketHandler::Listen(), LoadUnloadStation(), MoveWaypointsToBaseStations(), NetworkFindBroadcastIPs(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), ClientNetworkContentSocketHandler::OnConnect(), ClientNetworkContentSocketHandler::OnDisconnect(), ClientNetworkContentSocketHandler::OnDownloadComplete(), ClientNetworkContentSocketHandler::OnDownloadProgress(), NetworkGameWindow::OnInvalidateData(), NetworkContentListWindow::OnInvalidateData(), ClientNetworkContentSocketHandler::OnReceiveContentInfo(), ClientNetworkContentSocketHandler::OnReceiveData(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::Receive(), NetworkUDPSocketHandler::ReceivePackets(), RemoveFromRailBaseStation(), PacketReader::Reset(), RestoreTrainBackup(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), ClientNetworkContentSocketHandler::SelectAll(), ClientNetworkContentSocketHandler::SelectUpgrade(), NetworkUDPSocketHandler::SendPacket(), ShowNetworkContentListWindow(), NetworkContentListWindow::SortContentList(), ClientNetworkContentSocketHandler::UnselectAll(), UpdateWaypointOrder(), NetworkClientListPopupWindow::UpdateWidgetSize(), ViewportDrawBoundingBoxes(), ViewportSortParentSprites(), BaseSet< MusicSet, NUM_SONGS_AVAILABLE, GM_DIR >::~BaseSet(), ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler(), NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow(), and UnmappedChoiceList::~UnmappedChoiceList().

template<typename T, uint S>
FORCEINLINE bool SmallVector< T, S >::Contains ( const T &  item  )  const [inline]

Tests whether a item is present in the vector.

The '!=' operator of T is used for comparison.

Parameters:
item Item to test for
Returns:
true iff the item is present

Definition at line 162 of file smallvec_type.hpp.

Referenced by AddNearbyStation(), RefitWindow::BuildRefitList(), CheckHotkeyMatch(), ClientNetworkContentSocketHandler::DownloadContentInfo(), RefitWindow::DrawWidget(), BuildVehicleWindow::FilterEngineList(), FindIndustryToDeliver(), SmallVector< RefitOption, 32 >::Include(), NetworkFindBroadcastIPsInternal(), RefitVehicle(), and WhoCanServiceIndustry().

template<typename T, uint S>
FORCEINLINE T* SmallVector< T, S >::End (  )  [inline]

Get the pointer behind the last valid item.

Returns:
the pointer behind the last valid item

Definition at line 234 of file smallvec_type.hpp.

template<typename T, uint S>
FORCEINLINE const T* SmallVector< T, S >::End (  )  const [inline]

Get the pointer behind the last valid item (const).

Returns:
the pointer behind the last valid item

Definition at line 224 of file smallvec_type.hpp.

Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), AddCombinedSprite(), FiosFileScanner::AddFile(), ChangeGRFParamValueNames(), TCPConnecter::CheckCallbacks(), ClientNetworkContentSocketHandler::CheckDependencyState(), CheckSubsidised(), ClientNetworkContentSocketHandler::Clear(), LoadCheckData::Clear(), NetworkUDPSocketHandler::Close(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::CloseListeners(), CmdConvertRail(), CmdRemoveFromRailStation(), SmallVector< RefitOption, 32 >::Contains(), NetworkContentListWindow::DrawDetails(), DrawString(), NetworkClientListPopupWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), ClientNetworkContentSocketHandler::End(), SmallVector< RefitOption, 32 >::Erase(), NetworkContentListWindow::FilterContentList(), FinaliseAirportsArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), SmallVector< RefitOption, 32 >::Find(), FindClearedObject(), SmallVector< RefitOption, 32 >::FindIndex(), GamelogPrint(), GetBindAddresses(), GetCargoSummaryOfArticulatedVehicle(), ClientNetworkContentSocketHandler::GetContent(), BaseSet< MusicSet, NUM_SONGS_AVAILABLE, GM_DIR >::GetDescription(), GetLanguage(), LanguageMap::GetMapping(), LanguageMap::GetReverseMapping(), HasScenario(), NetworkHTTPSocketHandler::HTTPReceive(), IniSaveSettingList(), InitializeLanguagePacks(), TCPConnecter::KillAll(), NetworkUDPSocketHandler::Listen(), LoadUnloadStation(), MoveWaypointsToBaseStations(), NetworkFindBroadcastIPs(), NetworkUDPSocketHandler::NetworkUDPSocketHandler(), ClientNetworkContentSocketHandler::OnConnect(), ClientNetworkContentSocketHandler::OnDisconnect(), ClientNetworkContentSocketHandler::OnDownloadComplete(), ClientNetworkContentSocketHandler::OnDownloadProgress(), NetworkGameWindow::OnInvalidateData(), NetworkContentListWindow::OnInvalidateData(), ClientNetworkContentSocketHandler::OnReceiveContentInfo(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::Receive(), NetworkUDPSocketHandler::ReceivePackets(), RemoveFromRailBaseStation(), RestoreTrainBackup(), ClientNetworkContentSocketHandler::ReverseLookupDependency(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), ClientNetworkContentSocketHandler::SelectAll(), ClientNetworkContentSocketHandler::SelectUpgrade(), NetworkUDPSocketHandler::SendPacket(), ShowNetworkContentListWindow(), NetworkContentListWindow::SortContentList(), ClientNetworkContentSocketHandler::UnselectAll(), UpdateWaypointOrder(), NetworkClientListPopupWindow::UpdateWidgetSize(), ViewportDrawBoundingBoxes(), ViewportSortParentSprites(), BaseSet< MusicSet, NUM_SONGS_AVAILABLE, GM_DIR >::~BaseSet(), ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler(), NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow(), and UnmappedChoiceList::~UnmappedChoiceList().

template<typename T, uint S>
FORCEINLINE void SmallVector< T, S >::Erase ( T *  item  )  [inline]

Removes given item from this vector.

Parameters:
item item to remove
Note:
it has to be pointer to item in this map. It is overwritten by the last item.

Reimplemented in SmallMap< NetworkAddress, SOCKET, 4 >.

Definition at line 172 of file smallvec_type.hpp.

Referenced by AddNearbyStation(), TCPConnecter::CheckCallbacks(), NetworkHTTPSocketHandler::HTTPReceive(), and ClientNetworkContentSocketHandler::RemoveCallback().

template<typename T, uint S>
FORCEINLINE T* SmallVector< T, S >::Find ( const T &  item  )  [inline]

Search for the first occurrence of an item.

The '!=' operator of T is used for comparison.

Parameters:
item Item to search for
Returns:
The position of the item, or End() when not present

Definition at line 130 of file smallvec_type.hpp.

template<typename T, uint S>
FORCEINLINE const T* SmallVector< T, S >::Find ( const T &  item  )  const [inline]

Search for the first occurrence of an item.

The '!=' operator of T is used for comparison.

Parameters:
item Item to search for
Returns:
The position of the item, or End() when not present

Definition at line 116 of file smallvec_type.hpp.

Referenced by SmallVector< RefitOption, 32 >::Contains(), GetCargoSummaryOfArticulatedVehicle(), and ClientNetworkContentSocketHandler::RemoveCallback().

template<typename T, uint S>
FORCEINLINE int SmallVector< T, S >::FindIndex ( const T &  item  )  [inline]

Search for the first occurrence of an item.

The '!=' operator of T is used for comparison.

Parameters:
item Item to search for
Returns:
The position of the item, or -1 when not present

Definition at line 144 of file smallvec_type.hpp.

Referenced by FinalisePriceBaseMultipliers().

template<typename T, uint S>
FORCEINLINE T* SmallVector< T, S >::Get ( uint  index  )  [inline]

Get the pointer to item "number".

Parameters:
index the position of the item
Returns:
the pointer to the item

Definition at line 258 of file smallvec_type.hpp.

template<typename T, uint S>
FORCEINLINE const T* SmallVector< T, S >::Get ( uint  index  )  const [inline]
template<typename T, uint S>
FORCEINLINE bool SmallVector< T, S >::Include ( const T &  item  )  [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.

Parameters:
item Item to test for
Returns:
true iff the item is was already present

Definition at line 184 of file smallvec_type.hpp.

Referenced by ClientNetworkContentSocketHandler::AddCallback(), Hotkey< TerraformToolbarWindow >::AddKeycode(), RefitWindow::BuildRefitList(), CheckSubsidised(), DeliverGoodsToIndustry(), FindStationsAroundTiles(), NetworkContentDownloadStatusWindow::OnDownloadProgress(), RemoveFromRailBaseStation(), ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(), and UpdateTrainPowerProc().

template<typename T, uint S>
FORCEINLINE T& SmallVector< T, S >::operator[] ( uint  index  )  [inline]

Get item "number".

Parameters:
index the position of the item
Returns:
the item

Definition at line 283 of file smallvec_type.hpp.

template<typename T, uint S>
FORCEINLINE const T& SmallVector< T, S >::operator[] ( uint  index  )  const [inline]

Get item "number" (const).

Parameters:
index the position of the item
Returns:
the item

Definition at line 271 of file smallvec_type.hpp.


The documentation for this class was generated from the following file:

Generated on Sun Jan 9 16:03:21 2011 for OpenTTD by  doxygen 1.6.1