OpenTTD Source 20241224-master-gf74b0cf984
SmallSet< Tdir, items > Struct Template Reference

Set containing 'items' items of 'tile and Tdir' No tree structure is used because it would cause slowdowns in most usual cases. More...

Data Structures

struct  SSdata
 Element of set. More...
 

Public Member Functions

 SmallSet (const char *name)
 Constructor - just set default values and 'name'.
 
void Reset ()
 Reset variables to default values.
 
bool Overflowed ()
 Returns value of 'overflowed'.
 
bool IsEmpty ()
 Checks for empty set.
 
bool IsFull ()
 Checks for full set.
 
uint Items ()
 Reads the number of items.
 
bool Remove (TileIndex tile, Tdir dir)
 Tries to remove first instance of given tile and dir.
 
bool IsIn (TileIndex tile, Tdir dir)
 Tries to find given tile and dir in the set.
 
bool Add (TileIndex tile, Tdir dir)
 Adds tile & dir into the set, checks for full set Sets the 'overflowed' flag if the set was full.
 
bool Get (TileIndex *tile, Tdir *dir)
 Reads the last added element into the set.
 

Private Attributes

uint n
 
bool overflowed
 
const char * name
 
struct SmallSet::SSdata data [items]
 

Detailed Description

template<typename Tdir, uint items>
struct SmallSet< Tdir, items >

Set containing 'items' items of 'tile and Tdir' No tree structure is used because it would cause slowdowns in most usual cases.

Definition at line 53 of file signal.cpp.

Constructor & Destructor Documentation

◆ SmallSet()

template<typename Tdir , uint items>
SmallSet< Tdir, items >::SmallSet ( const char *  name)
inline

Constructor - just set default values and 'name'.

Definition at line 67 of file signal.cpp.

Member Function Documentation

◆ Add()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::Add ( TileIndex  tile,
Tdir  dir 
)
inline

Adds tile & dir into the set, checks for full set Sets the 'overflowed' flag if the set was full.

Parameters
tiletile
dirand dir to add
Returns
true iff the item could be added (set wasn't full)

Definition at line 153 of file signal.cpp.

References Debug, and SmallSet< Tdir, items >::IsFull().

◆ Get()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::Get ( TileIndex tile,
Tdir *  dir 
)
inline

Reads the last added element into the set.

Parameters
tilepointer where tile is written to
dirpointer where dir is written to
Returns
false iff the set was empty

Definition at line 174 of file signal.cpp.

◆ IsEmpty()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::IsEmpty ( )
inline

Checks for empty set.

Returns
is the set empty?

Definition at line 89 of file signal.cpp.

◆ IsFull()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::IsFull ( )
inline

Checks for full set.

Returns
is the set full?

Definition at line 98 of file signal.cpp.

References lengthof.

Referenced by SmallSet< Tdir, items >::Add().

◆ IsIn()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::IsIn ( TileIndex  tile,
Tdir  dir 
)
inline

Tries to find given tile and dir in the set.

Parameters
tiletile
dirand dir to find
Returns
true iff the tile & dir element was found

Definition at line 137 of file signal.cpp.

◆ Items()

template<typename Tdir , uint items>
uint SmallSet< Tdir, items >::Items ( )
inline

Reads the number of items.

Returns
current number of items

Definition at line 107 of file signal.cpp.

◆ Overflowed()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::Overflowed ( )
inline

Returns value of 'overflowed'.

Returns
did we try to overflow the set?

Definition at line 80 of file signal.cpp.

◆ Remove()

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::Remove ( TileIndex  tile,
Tdir  dir 
)
inline

Tries to remove first instance of given tile and dir.

Parameters
tiletile
dirand dir to remove
Returns
element was found and removed

Definition at line 119 of file signal.cpp.

◆ Reset()

template<typename Tdir , uint items>
void SmallSet< Tdir, items >::Reset ( )
inline

Reset variables to default values.

Definition at line 70 of file signal.cpp.

Field Documentation

◆ n

template<typename Tdir , uint items>
uint SmallSet< Tdir, items >::n
private

Definition at line 55 of file signal.cpp.

◆ name

template<typename Tdir , uint items>
const char* SmallSet< Tdir, items >::name
private

Definition at line 57 of file signal.cpp.

◆ overflowed

template<typename Tdir , uint items>
bool SmallSet< Tdir, items >::overflowed
private

Definition at line 56 of file signal.cpp.


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