SpiecsEngine
 
Loading...
Searching...
No Matches

◆ next_value()

template<typename K , typename V >
V * scl::linked_unordered_map< K, V >::next_value ( const K & key)
inline

Get the next element by the key.

Parameters
[in]keythe key.
Returns
Returns the next element.
Note
It's slow, so do not use it unnecessary.

@breif Returns nullptr if not find key.

Returns nullptr if not a prev value;

Iter the list.

Definition at line 307 of file LinkedUnorderedMap.h.

308 {
312 if (!has_key(key)) return nullptr;
313
314 std::shared_lock<std::shared_mutex> lock(m_Mutex);
315
319 if (key == m_Keys.back()) return nullptr;
320
324 for (auto it = m_Keys.begin(); it != m_Keys.end(); ++it)
325 {
326 if (*it == key)
327 {
328 return &(*std::next(it));
329 }
330 }
331
332 return nullptr;
333 }
std::shared_mutex m_Mutex
Mutex for this container.
bool has_key(const K &key)
Determine whether the key is in the container.
std::list< K > m_Keys
The container keeps iter in order.

References scl::linked_unordered_map< K, V >::has_key().