Horizon Official Technical Documentation
LockedLookupTable< Key, Value, Hash >::bucket_type Class Reference

Public Types

typedef bucket_data::iterator bucket_iterator
 

Public Member Functions

Value at (Key const &key, Value const &default_value)
 
void insert (Key const &key, Value const &value)
 
void erase (Key const &key)
 

Public Attributes

bucket_data data
 
boost::shared_mutex _mutex
 

Private Types

typedef std::pair< Key, Value > bucket_value
 
typedef std::vector< bucket_valuebucket_data
 

Private Member Functions

bucket_iterator find_entry_for (Key const &key)
 

Member Typedef Documentation

◆ bucket_data

template<typename Key , typename Value , typename Hash = std::hash<Key>>
typedef std::vector<bucket_value> LockedLookupTable< Key, Value, Hash >::bucket_type::bucket_data
private

◆ bucket_iterator

template<typename Key , typename Value , typename Hash = std::hash<Key>>
typedef bucket_data::iterator LockedLookupTable< Key, Value, Hash >::bucket_type::bucket_iterator

◆ bucket_value

template<typename Key , typename Value , typename Hash = std::hash<Key>>
typedef std::pair<Key, Value> LockedLookupTable< Key, Value, Hash >::bucket_type::bucket_value
private

Member Function Documentation

◆ at()

template<typename Key , typename Value , typename Hash = std::hash<Key>>
Value LockedLookupTable< Key, Value, Hash >::bucket_type::at ( Key const &  key,
Value const &  default_value 
)
inline
139 {
140 boost::shared_lock<boost::shared_mutex> lock(_mutex);
141 bucket_iterator const found_entry = find_entry_for(key);
142 return (found_entry == data.end()) ? default_value : found_entry->second;
143 }
bucket_data data
Definition: LockedLookupTable.hpp:164
bucket_data::iterator bucket_iterator
Definition: LockedLookupTable.hpp:136
bucket_iterator find_entry_for(Key const &key)
Definition: LockedLookupTable.hpp:168
boost::shared_mutex _mutex
Definition: LockedLookupTable.hpp:165

References LockedLookupTable< Key, Value, Hash >::bucket_type::_mutex, LockedLookupTable< Key, Value, Hash >::bucket_type::data, and LockedLookupTable< Key, Value, Hash >::bucket_type::find_entry_for().

Referenced by LockedLookupTable< Key, Value, Hash >::at().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ erase()

template<typename Key , typename Value , typename Hash = std::hash<Key>>
void LockedLookupTable< Key, Value, Hash >::bucket_type::erase ( Key const &  key)
inline
157 {
158 boost::unique_lock<boost::shared_mutex> lock(_mutex);
159 bucket_iterator const found_entry = find_entry_for(key);
160 if (found_entry != data.end())
161 data.erase(found_entry);
162 }

References LockedLookupTable< Key, Value, Hash >::bucket_type::_mutex, LockedLookupTable< Key, Value, Hash >::bucket_type::data, and LockedLookupTable< Key, Value, Hash >::bucket_type::find_entry_for().

Referenced by LockedLookupTable< Key, Value, Hash >::erase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_entry_for()

template<typename Key , typename Value , typename Hash = std::hash<Key>>
bucket_iterator LockedLookupTable< Key, Value, Hash >::bucket_type::find_entry_for ( Key const &  key)
inlineprivate
169 {
170 return std::find_if(data.begin(), data.end(),
171 [&](bucket_value const &item)
172 {
173 return item.first == key;
174 });
175 }
std::pair< Key, Value > bucket_value
Definition: LockedLookupTable.hpp:132

References LockedLookupTable< Key, Value, Hash >::bucket_type::data.

Referenced by LockedLookupTable< Key, Value, Hash >::bucket_type::at(), LockedLookupTable< Key, Value, Hash >::bucket_type::erase(), and LockedLookupTable< Key, Value, Hash >::bucket_type::insert().

+ Here is the caller graph for this function:

◆ insert()

template<typename Key , typename Value , typename Hash = std::hash<Key>>
void LockedLookupTable< Key, Value, Hash >::bucket_type::insert ( Key const &  key,
Value const &  value 
)
inline
146 {
147 boost::unique_lock<boost::shared_mutex> lock(_mutex);
148 bucket_iterator found_entry = find_entry_for(key);
149
150 if (found_entry != data.end())
151 data.erase(found_entry);
152
153 data.push_back(bucket_value(key, value));
154 }

References LockedLookupTable< Key, Value, Hash >::bucket_type::_mutex, LockedLookupTable< Key, Value, Hash >::bucket_type::data, and LockedLookupTable< Key, Value, Hash >::bucket_type::find_entry_for().

Referenced by LockedLookupTable< Key, Value, Hash >::insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _mutex

template<typename Key , typename Value , typename Hash = std::hash<Key>>
boost::shared_mutex LockedLookupTable< Key, Value, Hash >::bucket_type::_mutex
mutable

◆ data


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