Metall  v0.29
A persistent memory allocator for data-centric analytics
metall::container::string_key_store< _value_type, allocator_type > Class Template Reference

A ke-value store that uses string for its key. More...

#include </home/runner/work/metall/metall/include/metall/container/string_key_store.hpp>

Public Types

using key_type = std::string_view
 
using value_type = _value_type
 
using locator_type = string_key_store_locator< typename map_type::const_iterator >
 

Public Member Functions

 string_key_store (const allocator_type &allocator=allocator_type())
 Constructor. More...
 
 string_key_store (const bool unique, const uint64_t hash_seed, const allocator_type &allocator=allocator_type())
 Constructor. More...
 
 string_key_store (const string_key_store &)=default
 Copy constructor. More...
 
 string_key_store (const string_key_store &other, const allocator_type &alloc)
 Allocator-extended copy constructor. More...
 
 string_key_store (string_key_store &&) noexcept=default
 Move constructor. More...
 
 string_key_store (string_key_store &&other, const allocator_type &alloc) noexcept
 Allocator-extended move constructor. More...
 
string_key_storeoperator= (const string_key_store &)=default
 Copy assignment operator. More...
 
string_key_storeoperator= (string_key_store &&) noexcept=default
 Move assignment operator. More...
 
bool insert (const key_type &key)
 Inserts a key with the default value. If the unique parameter in the constructor was set to true and a duplicate key item already exists, this function does nothing and returns false. More...
 
bool insert (const key_type &key, const value_type &value)
 Inserts an item. Suppose the unique parameter was set to true in the constructor and a duplicate key item exists. In that case, this function just updates the value of the existing one. More...
 
bool insert (const key_type &key, value_type &&value)
 Insert() with move operator version. More...
 
void clear ()
 Clear all contents. This call does not reduce the memory usage. More...
 
std::size_t count (const key_type &key) const
 Counts the number of items associated with the key. More...
 
std::size_t size () const
 Returns the number of elements in this container. More...
 
const key_type key (const locator_type &position) const
 Returns the key of the element at 'position'. More...
 
value_typevalue (const locator_type &position)
 Returns the value of the element at 'position'. More...
 
const value_typevalue (const locator_type &position) const
 Returns the value of the element at 'position'. More...
 
locator_type find (const key_type &key) const
 Finds an element with key equivalent to 'key'. More...
 
std::pair< locator_type, locator_typeequal_range (const key_type &key) const
 Returns a range containing all elements with key key in the container. More...
 
locator_type begin () const
 Return an iterator that points the first element in the container. More...
 
locator_type end () const
 Returns an iterator to the element following the last element. More...
 
std::size_t erase (const key_type &key)
 Removes all elements with the key equivalent to key. More...
 
locator_type erase (const locator_type &position)
 Removes the element at 'position'. More...
 
std::size_t max_id_probe_distance () const
 Returns the maximum ID probe distance. In other words, the maximum number of key pairs that have the same hash value. More...
 
void rehash ()
 Rehash elements. More...
 
allocator_type get_allocator ()
 Returns an instance of the internal allocator. More...
 
bool unique () const
 Returns if this container inserts keys uniquely. More...
 
bool hash_seed () const
 Returns the hash seed. More...
 

Detailed Description

template<typename _value_type, typename allocator_type = metall::manager::allocator_type<std::byte>>
class metall::container::string_key_store< _value_type, allocator_type >

A ke-value store that uses string for its key.

Warning
This container is designed to work as the top-level container, i.e., it does not work if used inside another container.
Template Parameters
_value_typeA value type.
allocator_typeAn allocator type.

Member Typedef Documentation

◆ key_type

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
using metall::container::string_key_store< _value_type, allocator_type >::key_type = std::string_view

◆ value_type

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
using metall::container::string_key_store< _value_type, allocator_type >::value_type = _value_type

◆ locator_type

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
using metall::container::string_key_store< _value_type, allocator_type >::locator_type = string_key_store_locator<typename map_type::const_iterator>

Constructor & Destructor Documentation

◆ string_key_store() [1/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( const allocator_type &  allocator = allocator_type())
inlineexplicit

Constructor.

Parameters
allocatorAn allocator object.

◆ string_key_store() [2/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( const bool  unique,
const uint64_t  hash_seed,
const allocator_type &  allocator = allocator_type() 
)
inline

Constructor.

Parameters
uniqueAccept duplicate keys if false is specified.
hash_seedHash function seed.
allocatorAn allocator object.

◆ string_key_store() [3/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( const string_key_store< _value_type, allocator_type > &  )
default

Copy constructor.

◆ string_key_store() [4/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( const string_key_store< _value_type, allocator_type > &  other,
const allocator_type &  alloc 
)
inline

Allocator-extended copy constructor.

◆ string_key_store() [5/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( string_key_store< _value_type, allocator_type > &&  )
defaultnoexcept

Move constructor.

◆ string_key_store() [6/6]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
metall::container::string_key_store< _value_type, allocator_type >::string_key_store ( string_key_store< _value_type, allocator_type > &&  other,
const allocator_type &  alloc 
)
inlinenoexcept

Allocator-extended move constructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
string_key_store& metall::container::string_key_store< _value_type, allocator_type >::operator= ( const string_key_store< _value_type, allocator_type > &  )
default

Copy assignment operator.

◆ operator=() [2/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
string_key_store& metall::container::string_key_store< _value_type, allocator_type >::operator= ( string_key_store< _value_type, allocator_type > &&  )
defaultnoexcept

Move assignment operator.

◆ insert() [1/3]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
bool metall::container::string_key_store< _value_type, allocator_type >::insert ( const key_type key)
inline

Inserts a key with the default value. If the unique parameter in the constructor was set to true and a duplicate key item already exists, this function does nothing and returns false.

Parameters
keyA key to insert.
Returns
True if an item is inserted; otherwise, false.

◆ insert() [2/3]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
bool metall::container::string_key_store< _value_type, allocator_type >::insert ( const key_type key,
const value_type value 
)
inline

Inserts an item. Suppose the unique parameter was set to true in the constructor and a duplicate key item exists. In that case, this function just updates the value of the existing one.

Parameters
keyA key to insert.
valueA value to insert.
Returns
Always true.

◆ insert() [3/3]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
bool metall::container::string_key_store< _value_type, allocator_type >::insert ( const key_type key,
value_type &&  value 
)
inline

Insert() with move operator version.

Parameters
keyA key to insert.
valueA value to insert.
Returns
Always true.

◆ clear()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
void metall::container::string_key_store< _value_type, allocator_type >::clear ( )
inline

Clear all contents. This call does not reduce the memory usage.

◆ count()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
std::size_t metall::container::string_key_store< _value_type, allocator_type >::count ( const key_type key) const
inline

Counts the number of items associated with the key.

Parameters
keyA key to count.
Returns
The number of items associated with the key.

◆ size()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
std::size_t metall::container::string_key_store< _value_type, allocator_type >::size ( ) const
inline

Returns the number of elements in this container.

Returns
The number of elements in this container.

◆ key()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
const key_type metall::container::string_key_store< _value_type, allocator_type >::key ( const locator_type position) const
inline

Returns the key of the element at 'position'.

Parameters
positionA locator object.
Returns
The key of the element at 'position'.

◆ value() [1/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
value_type& metall::container::string_key_store< _value_type, allocator_type >::value ( const locator_type position)
inline

Returns the value of the element at 'position'.

Parameters
positionA locator object.
Returns
The value of the element at 'position'.

◆ value() [2/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
const value_type& metall::container::string_key_store< _value_type, allocator_type >::value ( const locator_type position) const
inline

Returns the value of the element at 'position'.

Parameters
positionA locator object.
Returns
The value of the element at 'position' as const.

◆ find()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
locator_type metall::container::string_key_store< _value_type, allocator_type >::find ( const key_type key) const
inline

Finds an element with key equivalent to 'key'.

Parameters
keyThe key of an element to find.
Returns
An locator object that points the found element.

◆ equal_range()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
std::pair<locator_type, locator_type> metall::container::string_key_store< _value_type, allocator_type >::equal_range ( const key_type key) const
inline

Returns a range containing all elements with key key in the container.

Parameters
keyThe key of elements to find.
Returns
A pair of locator objects. The range is defined by two locators. The first points to the first element of the range, and the second points to the element following the last element of the range.

◆ begin()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
locator_type metall::container::string_key_store< _value_type, allocator_type >::begin ( ) const
inline

Return an iterator that points the first element in the container.

Returns
An iterator that points the first element in the container.

◆ end()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
locator_type metall::container::string_key_store< _value_type, allocator_type >::end ( ) const
inline

Returns an iterator to the element following the last element.

Returns
An iterator to the element following the last element.

◆ erase() [1/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
std::size_t metall::container::string_key_store< _value_type, allocator_type >::erase ( const key_type key)
inline

Removes all elements with the key equivalent to key.

Parameters
keyThe key of elements to remove.
Returns
The number of elements removed.

◆ erase() [2/2]

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
locator_type metall::container::string_key_store< _value_type, allocator_type >::erase ( const locator_type position)
inline

Removes the element at 'position'.

Parameters
positionThe position of an element to remove.
Returns
A locator that points to the next element of the removed one.

◆ max_id_probe_distance()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
std::size_t metall::container::string_key_store< _value_type, allocator_type >::max_id_probe_distance ( ) const
inline

Returns the maximum ID probe distance. In other words, the maximum number of key pairs that have the same hash value.

Returns
The maximum ID probe distance.

◆ rehash()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
void metall::container::string_key_store< _value_type, allocator_type >::rehash ( )
inline

Rehash elements.

◆ get_allocator()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
allocator_type metall::container::string_key_store< _value_type, allocator_type >::get_allocator ( )
inline

Returns an instance of the internal allocator.

Returns
An instance of the internal allocator.

◆ unique()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
bool metall::container::string_key_store< _value_type, allocator_type >::unique ( ) const
inline

Returns if this container inserts keys uniquely.

Returns
True if this container inserts key avoiding duplicates; otherwise false.

◆ hash_seed()

template<typename _value_type , typename allocator_type = metall::manager::allocator_type<std::byte>>
bool metall::container::string_key_store< _value_type, allocator_type >::hash_seed ( ) const
inline

Returns the hash seed.

Returns
Hash seed.

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