OpenTTD Source 20260304-master-g1baaa74679
HashTableSlot< TItem > Struct Template Reference

Public Types

typedef TItem::Key Key
 Make Titem::Key a property of HashTable.

Public Member Functions

void Clear ()
 Clears the slot by simple forgetting its items.
const TItem * Find (const Key &key) const
 Linear search for item with given key through the given blob.
TItem * Find (const Key &key)
 Linear search for item with given key through the given blob.
void Attach (TItem &new_item)
 Add new item to the slot.
bool Detach (TItem &item_to_remove)
 Remove item from a slot.
TItem * Detach (const Key &key)
 Remove and return item from a slot.

Data Fields

TItem * first_item = nullptr

Detailed Description

template<class TItem>
struct HashTableSlot< TItem >

Definition at line 14 of file hashtable.hpp.

Member Typedef Documentation

◆ Key

template<class TItem>
typedef TItem::Key HashTableSlot< TItem >::Key

Make Titem::Key a property of HashTable.

Definition at line 15 of file hashtable.hpp.

Member Function Documentation

◆ Attach()

template<class TItem>
void HashTableSlot< TItem >::Attach ( TItem & new_item)
inline

Add new item to the slot.

Parameters
new_itemThe item to insert.

Definition at line 61 of file hashtable.hpp.

Referenced by HashTable< Titem, Thash_bits_ >::Push().

◆ Clear()

template<class TItem>
void HashTableSlot< TItem >::Clear ( )
inline

Clears the slot by simple forgetting its items.

Definition at line 20 of file hashtable.hpp.

◆ Detach() [1/2]

template<class TItem>
TItem * HashTableSlot< TItem >::Detach ( const Key & key)
inline

Remove and return item from a slot.

Parameters
keyThe key to search for.
Returns
The removed item, or nullptr when nothing was removed.

Definition at line 99 of file hashtable.hpp.

◆ Detach() [2/2]

template<class TItem>
bool HashTableSlot< TItem >::Detach ( TItem & item_to_remove)
inline

Remove item from a slot.

Parameters
item_to_removeThe item to remove.
Returns
true iff the item could be removed.

Definition at line 73 of file hashtable.hpp.

Referenced by HashTable< Titem, Thash_bits_ >::TryPop(), and HashTable< Titem, Thash_bits_ >::TryPop().

◆ Find() [1/2]

template<class TItem>
TItem * HashTableSlot< TItem >::Find ( const Key & key)
inline

Linear search for item with given key through the given blob.

Parameters
keyThe key to find.
Returns
The found item, or nullptr.

Definition at line 46 of file hashtable.hpp.

◆ Find() [2/2]

template<class TItem>
const TItem * HashTableSlot< TItem >::Find ( const Key & key) const
inline

Linear search for item with given key through the given blob.

Parameters
keyThe key to find.
Returns
The found item, or nullptr.

Definition at line 30 of file hashtable.hpp.

Referenced by HashTable< Titem, Thash_bits_ >::Find(), HashTable< Titem, Thash_bits_ >::Find(), and HashTable< Titem, Thash_bits_ >::Push().

Field Documentation

◆ first_item

template<class TItem>
TItem* HashTableSlot< TItem >::first_item = nullptr

Definition at line 17 of file hashtable.hpp.


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