OpenTTD Source 20250428-master-ga5578166bb
SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size > Class Template Reference

A simplified pool which stores values instead of pointers and doesn't redefine operator new/delete. More...

#include <smallstack_type.hpp>

Data Structures

struct  SimplePoolPoolItem
 

Public Member Functions

Titem & Get (Tindex index)
 Get the item at position index.
 
Tindex Create ()
 Create a new item and return its index.
 
void Destroy (Tindex index)
 Destroy (or rather invalidate) the item at the given index.
 

Private Member Functions

Tindex FindFirstFree ()
 

Private Attributes

Tindex first_unused
 
Tindex first_free
 
std::vector< SimplePoolPoolItemdata
 

Detailed Description

template<typename Titem, typename Tindex, Tindex Tgrowth_step, Tindex Tmax_size>
class SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >

A simplified pool which stores values instead of pointers and doesn't redefine operator new/delete.

It also never zeroes memory and always reuses it.

Definition at line 19 of file smallstack_type.hpp.

Constructor & Destructor Documentation

◆ SimplePool()

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::SimplePool ( )
inline

Definition at line 21 of file smallstack_type.hpp.

Member Function Documentation

◆ Create()

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
Tindex SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::Create ( )
inline

Create a new item and return its index.

Returns
Index of new item.

Definition at line 33 of file smallstack_type.hpp.

Referenced by SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Push().

◆ Destroy()

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
void SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::Destroy ( Tindex  index)
inline

Destroy (or rather invalidate) the item at the given index.

Parameters
indexIndex of item to be destroyed.

Definition at line 48 of file smallstack_type.hpp.

Referenced by SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Pop().

◆ FindFirstFree()

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
Tindex SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::FindFirstFree ( )
inlineprivate

Definition at line 56 of file smallstack_type.hpp.

◆ Get()

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
Titem & SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::Get ( Tindex  index)
inline

Field Documentation

◆ data

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
std::vector<SimplePoolPoolItem> SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::data
private

Definition at line 76 of file smallstack_type.hpp.

◆ first_free

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
Tindex SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::first_free
private

Definition at line 74 of file smallstack_type.hpp.

◆ first_unused

template<typename Titem , typename Tindex , Tindex Tgrowth_step, Tindex Tmax_size>
Tindex SimplePool< Titem, Tindex, Tgrowth_step, Tmax_size >::first_unused
private

Definition at line 73 of file smallstack_type.hpp.


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