PMDK C++ bindings
1.13.0-git23.gf49772ac
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Radix tree is an associative, ordered container. More...
#include <libpmemobj++/experimental/radix_tree.hpp>
Classes | |
struct | leaf |
This is the structure which 'holds' key/value pair. More... | |
struct | node |
This is internal node. More... | |
struct | radix_tree_iterator |
Radix tree iterator supports multipass and bidirectional iteration. More... | |
Public Member Functions | |
radix_tree () | |
Default radix tree constructor. More... | |
template<class InputIt > | |
radix_tree (InputIt first, InputIt last) | |
Constructs the container with the contents of the range [first, last). More... | |
radix_tree (const radix_tree &m) | |
Copy constructor. More... | |
radix_tree (radix_tree &&m) | |
Move constructor. More... | |
radix_tree (std::initializer_list< value_type > il) | |
Constructs the container with the contents of the initializer list init. More... | |
radix_tree & | operator= (const radix_tree &m) |
Copy assignment operator. More... | |
radix_tree & | operator= (radix_tree &&m) |
Move assignment operator. More... | |
radix_tree & | operator= (std::initializer_list< value_type > ilist) |
Replaces the contents with those identified by initializer list ilist transactionally. More... | |
~radix_tree () | |
Destructor. | |
std::pair< iterator, bool > | insert (const value_type &v) |
Inserts element if the tree doesn't already contain an element with an equivalent key. More... | |
std::pair< iterator, bool > | insert (value_type &&v) |
Inserts element using move semantic if the tree doesn't already contain an element with an equivalent key. More... | |
template<class InputIterator > | |
void | insert (InputIterator first, InputIterator last) |
Inserts elements from range [first, last). More... | |
void | insert (std::initializer_list< value_type > il) |
Inserts elements from initializer list il. More... | |
template<typename K , typename BV = BytesView, class... Args> | |
auto | try_emplace (K &&k, Args &&... args) -> typename std::enable_if< detail::has_is_transparent< BV >::value &&!std::is_same< typename std::remove_const< typename std::remove_reference< K >::type >::type, key_type >::value, std::pair< iterator, bool >>::type |
If a key equivalent to k already exists in the container, does nothing. More... | |
iterator | erase (const_iterator pos) |
Removes the element at pos from the container. More... | |
iterator | erase (const_iterator first, const_iterator last) |
Removes the elements in the range [first; last), which must be a valid range in *this. More... | |
size_type | erase (const key_type &k) |
Removes the element (if one exists) with the key equivalent to key. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value && !std::is_same<K, iterator>::value && !std::is_same<K, const_iterator>::value, K>::type> | |
size_type | erase (const K &k) |
Removes the element (if one exists) with the key equivalent to key. More... | |
void | clear () |
Erases all elements from the container transactionally. More... | |
size_type | count (const key_type &k) const |
Returns the number of elements with key that compares equivalent to the specified argument. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
size_type | count (const K &k) const |
Returns the number of elements with key that compares equivalent to the specified argument. More... | |
iterator | find (const key_type &k) |
Finds an element with key equivalent to key. More... | |
const_iterator | find (const key_type &k) const |
Finds an element with key equivalent to key. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
iterator | find (const K &k) |
Finds an element with key equivalent to key. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
const_iterator | find (const K &k) const |
Finds an element with key equivalent to key. More... | |
iterator | lower_bound (const key_type &k) |
Returns an iterator pointing to the first element that is not less than (i.e. More... | |
const_iterator | lower_bound (const key_type &k) const |
Returns an iterator pointing to the first element that is not less than (i.e. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
iterator | lower_bound (const K &k) |
Returns an iterator pointing to the first element that is not less than (i.e. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
const_iterator | lower_bound (const K &k) const |
Returns an iterator pointing to the first element that is not less than (i.e. More... | |
iterator | upper_bound (const key_type &k) |
Returns an iterator pointing to the first element that is greater than key. More... | |
const_iterator | upper_bound (const key_type &k) const |
Returns an iterator pointing to the first element that is greater than key. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
iterator | upper_bound (const K &k) |
Returns an iterator pointing to the first element that is greater than key. More... | |
template<typename K , typename = typename std::enable_if< detail::has_is_transparent<BytesView>::value, K>::type> | |
const_iterator | upper_bound (const K &k) const |
Returns an iterator pointing to the first element that is greater than key. More... | |
iterator | begin () |
Returns an iterator to the first element of the container. More... | |
iterator | end () |
Returns an iterator to the element following the last element of the map. More... | |
const_iterator | cbegin () const |
Returns a const iterator to the first element of the container. More... | |
const_iterator | cend () const |
Returns a const iterator to the element following the last element of the map. More... | |
const_iterator | begin () const |
Returns a const iterator to the first element of the container. More... | |
const_iterator | end () const |
Returns a const iterator to the element following the last element of the map. More... | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the beginning. More... | |
reverse_iterator | rend () |
Returns a reverse iterator to the end. More... | |
const_reverse_iterator | crbegin () const |
Returns a const, reverse iterator to the beginning. More... | |
const_reverse_iterator | crend () const |
Returns a const, reverse iterator to the end. More... | |
bool | empty () const noexcept |
Checks whether the container is empty. More... | |
size_type | max_size () const noexcept |
uint64_t | size () const noexcept |
void | swap (radix_tree &rhs) |
Member swap. More... | |
template<bool Mt = MtMode, typename Enable = typename std::enable_if<Mt>::type> | |
void | garbage_collect () |
Tries to collect and free some garbage produced by erase, clear, insert_or_assign or assign_val in concurrent mode (if MtMode == true). More... | |
template<bool Mt = MtMode, typename Enable = typename std::enable_if<Mt>::type> | |
void | garbage_collect_force () |
Performs full epochs synchronisation. More... | |
template<bool Mt = MtMode, typename Enable = typename std::enable_if<Mt>::type> | |
void | runtime_initialize_mt (ebr *e=new ebr()) |
If MtMode == true, this function must be called after each application restart. More... | |
template<bool Mt = MtMode, typename Enable = typename std::enable_if<Mt>::type> | |
void | runtime_finalize_mt () |
If MtMode == true, this function must be called before each application close and before calling radix destructor or there will be possible a memory leak. | |
template<bool Mt = MtMode, typename Enable = typename std::enable_if<Mt>::type> | |
worker_type | register_worker () |
Registers and returns a new worker, which can perform critical operations (accessing some shared data that can be removed in other threads). More... | |
template<class... Args> | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | try_emplace (const key_type &k, Args &&... args) |
If a key equivalent to k already exists in the container, does nothing. More... | |
template<class... Args> | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | emplace (Args &&... args) |
Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. More... | |
template<typename P , typename > | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | insert (P &&p) |
Inserts element if the tree doesn't already contain an element with an equivalent key. More... | |
template<class... Args> | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | try_emplace (key_type &&k, Args &&... args) |
If a key equivalent to k already exists in the container, does nothing. More... | |
template<typename M > | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | insert_or_assign (const key_type &k, M &&obj) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k. More... | |
template<typename M > | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | insert_or_assign (key_type &&k, M &&obj) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k. More... | |
template<typename M , typename K , typename > | |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > | insert_or_assign (K &&k, M &&obj) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k. More... | |
Private Member Functions | |
template<bool Lower, typename K > | |
bool | validate_bound (const_iterator it, const K &key) const |
Checks if iterator points to element which compares bigger (or equal) to key. | |
template<bool Mt = MtMode> | |
std::enable_if< Mt, bool >::type | validate_path (const path_type &path) const |
Checks if any node in the. More... | |
template<typename T > | |
void | free (persistent_ptr< T > ptr) |
Deletes node/leaf pointed by ptr. More... | |
void | check_pmem () |
Private helper function. More... | |
void | check_tx_stage_work () |
Private helper function. More... | |
Radix tree is an associative, ordered container.
Its API is similar to the API of std::map.
Unlike std::map radix tree does not use comparison (std::less or equivalent) to locate elements. Instead, keys are mapped to a sequence of bytes using user-provided BytesView type. The key's bytes uniquely define the position of an element. In some way, it is similar to a hash table (BytesView can be treated as a hash function) but with sorted elements.
The elements' ordering is defined based on the BytesView mapping. The byte sequences are compared using a function equivalent to std::string::compare.
BytesView should accept a pointer to the key type in a constructor and provide operator[] (should return a byte at the specified position in the byte representation of value) and size (should return size of value in bytes) method. The declaration should be as following:
By default, implementation for pmem::obj::basic_inline_string<CharT, Traits> and unsigned integral types is provided. Note that integral types are assumed to be in little-endian.
Iterators and references are stable (are not invalidated by inserts or erases of other elements nor by assigning to the value) for all value types except basic_inline_string<CharT, Traits>.
In case of basic_inline_string<CharT, Traits>, iterators and references are not invalidated by other inserts or erases, but might be invalidated by assigning new value to the element. Using find(K).assign_val("new_value") may invalidate other iterators and references to the element with key K.
swap() invalidates all references and iterators.
MtMode enables single-writer multiple-readers concurrency with read uncommitted isolation. In this, mode user HAS TO call runtime_initialize_mt after each application restart and runtime_finalize_mt before destroying radix tree.
Enabling MtMode has the following effects:
By default, concurrency is not enabled (it is not allowed to perform concurrent operations on radix tree).
An example of custom BytesView implementation:
pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::radix_tree |
Default radix tree constructor.
Constructs an empty container.
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::radix_tree | ( | InputIt | first, |
InputIt | last | ||
) |
Constructs the container with the contents of the range [first, last).
If multiple elements in the range have keys that compare equivalent, the first element is inserted.
[in] | first | first iterator of inserted range. |
[in] | last | last iterator of inserted range. |
InputIt must meet the requirements of LegacyInputIterator.
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
pmem::transaction_alloc_error | when allocating memory for inserted elements in transaction failed. |
rethrows | element constructor exception. |
pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::radix_tree | ( | const radix_tree< Key, Value, BytesView, MtMode > & | m | ) |
Copy constructor.
Constructs the container with the copy of the contents of other.
[in] | m | reference to the radix_tree to be copied. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::radix_tree | ( | radix_tree< Key, Value, BytesView, MtMode > && | m | ) |
Move constructor.
Constructs the container with the contents of other using move semantics. After the move, other is guaranteed to be empty().
[in] | m | rvalue reference to the radix_tree to be moved from. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::radix_tree | ( | std::initializer_list< value_type > | il | ) |
Constructs the container with the contents of the initializer list init.
[in] | il | initializer list with content to be constructed. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::begin |
Returns an iterator to the first element of the container.
If the map is empty, the returned iterator will be equal to end().
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::begin |
Returns a const iterator to the first element of the container.
If the map is empty, the returned iterator will be equal to end().
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::cbegin |
Returns a const iterator to the first element of the container.
If the map is empty, the returned iterator will be equal to end().
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::cend |
Returns a const iterator to the element following the last element of the map.
This element acts as a placeholder; attempting to access it results in undefined behavior.
|
private |
Private helper function.
Checks if radix tree resides on pmem and throws an exception if not.
pool_error | if radix tree doesn't reside on pmem. |
|
private |
Private helper function.
Checks if current transaction stage is equal to TX_STAGE_WORK and throws an exception otherwise.
pmem::transaction_scope_error | if current transaction stage is not equal to TX_STAGE_WORK. |
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::clear |
Erases all elements from the container transactionally.
pmem::transaction_error | when snapshotting failed. |
radix_tree< Key, Value, BytesView, MtMode >::size_type pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::count | ( | const K & | k | ) | const |
Returns the number of elements with key that compares equivalent to the specified argument.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value of the element to count. |
radix_tree< Key, Value, BytesView, MtMode >::size_type pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::count | ( | const key_type & | k | ) | const |
Returns the number of elements with key that compares equivalent to the specified argument.
[in] | k | key value of the element to count. |
radix_tree< Key, Value, BytesView, MtMode >::const_reverse_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::crbegin |
Returns a const, reverse iterator to the beginning.
Using reverse iterators in concurrent environment is not safe.
radix_tree< Key, Value, BytesView, MtMode >::const_reverse_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::crend |
Returns a const, reverse iterator to the end.
Using reverse iterators in concurrent environment is not safe.
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::emplace | ( | Args &&... | args | ) |
Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container.
Careful use of emplace allows the new element to be constructed while avoiding unnecessary copy or move operations. The constructor of the new element (i.e. std::pair<const Key, T>) is called with exactly the same arguments as supplied to emplace, forwarded via std::forward<Args>(args).... The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately.
No iterators or references are invalidated.
[in] | args | arguments to forward to the constructor of the element |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
|
noexcept |
Checks whether the container is empty.
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::end |
Returns an iterator to the element following the last element of the map.
This element acts as a placeholder; attempting to access it results in undefined behavior.
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::end |
Returns a const iterator to the element following the last element of the map.
This element acts as a placeholder; attempting to access it results in undefined behavior.
radix_tree< Key, Value, BytesView, MtMode >::size_type pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::erase | ( | const K & | k | ) |
Removes the element (if one exists) with the key equivalent to key.
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value of the elements to remove |
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
radix_tree< Key, Value, BytesView, MtMode >::size_type pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::erase | ( | const key_type & | k | ) |
Removes the element (if one exists) with the key equivalent to key.
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
[in] | k | key value of the elements to remove. |
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::erase | ( | const_iterator | first, |
const_iterator | last | ||
) |
Removes the elements in the range [first; last), which must be a valid range in *this.
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
[in] | first | first iterator in the range of elements to remove. |
[in] | last | last iterator in the range of elements to remove. |
pmem::transaction_error | when snapshotting failed. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::erase | ( | const_iterator | pos | ) |
Removes the element at pos from the container.
References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
[in] | pos | iterator to the element to remove. |
pmem::transaction_error | when snapshotting failed. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::find | ( | const K & | k | ) |
Finds an element with key equivalent to key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value of the element to search for. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::find | ( | const K & | k | ) | const |
Finds an element with key equivalent to key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value of the element to search for. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::find | ( | const key_type & | k | ) |
Finds an element with key equivalent to key.
[in] | k | key value of the element to search for. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::find | ( | const key_type & | k | ) | const |
Finds an element with key equivalent to key.
[in] | k | key value of the element to search for. |
|
private |
Deletes node/leaf pointed by ptr.
If concurrent mode is used, adds element to the garbage list. Otherwise, frees the element immediately.
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::garbage_collect |
Tries to collect and free some garbage produced by erase, clear, insert_or_assign or assign_val in concurrent mode (if MtMode == true).
It is not guaranteed that this method will free any memory. It depends on operations currently performed by other threads.
Garbage is not automatically collected on move/copy ctor/assignment.
pmem::transaction_error | when snapshotting failed. |
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::garbage_collect_force |
Performs full epochs synchronisation.
Transactionally collects and frees all garbage produced by erase, clear, insert_or_assign or assign_val in concurrent mode (if MtMode == true).
Garbage is not automatically collected on move/copy ctor/assignment.
pmem::transaction_error | when snapshotting failed. |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert | ( | const value_type & | v | ) |
Inserts element if the tree doesn't already contain an element with an equivalent key.
[in] | v | element value to insert. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert | ( | InputIterator | first, |
InputIterator | last | ||
) |
Inserts elements from range [first, last).
[in] | first | first iterator of inserted range. |
[in] | last | last iterator of inserted range. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert | ( | P && | p | ) |
Inserts element if the tree doesn't already contain an element with an equivalent key.
This overload is equivalent to emplace(std::forward<P>(value)) and only participates in overload resolution if std::is_constructible<value_type, P&&>::value == true.
[in] | p | element value to insert. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert | ( | std::initializer_list< value_type > | il | ) |
Inserts elements from initializer list il.
[in] | il | initializer list to insert the values from. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair< typename radix_tree< Key, Value, BytesView, MtMode >::iterator, bool > pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert | ( | value_type && | v | ) |
Inserts element using move semantic if the tree doesn't already contain an element with an equivalent key.
[in] | v | element value to insert. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert_or_assign | ( | const key_type & | k, |
M && | obj | ||
) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k.
If the key does not exist, inserts the new value as if by insert, constructing it from value_type(k, std::forward<M>(obj)).
[in] | k | the key used both to look up and to insert if not found. |
[in] | obj | the value to insert or assign. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert_or_assign | ( | K && | k, |
M && | obj | ||
) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k.
If the key does not exist, inserts the new value as if by insert, constructing it from value_type(std::forward<K>(k), std::forward<M>(obj)).
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | the key used both to look up and to insert if not found. |
[in] | obj | the value to insert or assign. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::insert_or_assign | ( | key_type && | k, |
M && | obj | ||
) |
If a key equivalent to k already exists in the container, assigns std::forward<M>(obj) to the mapped_type corresponding to the key k.
If the key does not exist, inserts the new value as if by insert, constructing it from value_type(std::move(k), std::forward<M>(obj))
[in] | k | the key used both to look up and to insert if not found |
[in] | obj | the value to insert or assign |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::lower_bound | ( | const K & | k | ) |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::lower_bound | ( | const K & | k | ) | const |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::lower_bound | ( | const key_type & | k | ) |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::lower_bound | ( | const key_type & | k | ) | const |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
[in] | k | key value to compare the elements to. |
|
noexcept |
radix_tree< Key, Value, BytesView, MtMode > & pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::operator= | ( | const radix_tree< Key, Value, BytesView, MtMode > & | other | ) |
Copy assignment operator.
Replaces the contents with a copy of the contents of other transactionally.
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor's exception. |
radix_tree< Key, Value, BytesView, MtMode > & pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::operator= | ( | radix_tree< Key, Value, BytesView, MtMode > && | other | ) |
Move assignment operator.
Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container) transactionally. Other is in a valid but empty state afterwards.
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_error | when snapshotting failed. |
radix_tree< Key, Value, BytesView, MtMode > & pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::operator= | ( | std::initializer_list< value_type > | ilist | ) |
Replaces the contents with those identified by initializer list ilist transactionally.
[in] | ilist | initializer list to use as data source. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
radix_tree< Key, Value, BytesView, MtMode >::reverse_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::rbegin |
Returns a reverse iterator to the beginning.
Using reverse iterators in concurrent environment is not safe.
radix_tree< Key, Value, BytesView, MtMode >::worker_type pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::register_worker |
Registers and returns a new worker, which can perform critical operations (accessing some shared data that can be removed in other threads).
There can be only one worker per thread. The worker will be automatically unregistered in the destructor.
radix_tree< Key, Value, BytesView, MtMode >::reverse_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::rend |
Returns a reverse iterator to the end.
Using reverse iterators in concurrent environment is not safe.
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::runtime_initialize_mt | ( | ebr * | e = new ebr() | ) |
If MtMode == true, this function must be called after each application restart.
It is necessary to call runtime_finalize_mt() before closing the application.
[in] | e | pointer to already created ebr, default it will be created automatically. |
|
noexcept |
void pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::swap | ( | radix_tree< Key, Value, BytesView, MtMode > & | rhs | ) |
Member swap.
Exchanges *this with
rhs |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::try_emplace | ( | const key_type & | k, |
Args &&... | args | ||
) |
If a key equivalent to k already exists in the container, does nothing.
Otherwise, behaves like emplace except that the element is constructed as value_type(std::piecewise_construct, std::forward_as_tuple(k), std::forward_as_tuple(std::forward<Args>(args)...))
Unlike insert or emplace, this method do not move from rvalue arguments if the insertion does not happen, which makes it easy to manipulate maps whose values are move-only types. In addition, try_emplace treats the key and the arguments to the mapped_type separately, unlike emplace, which requires the arguments to construct a value_type (that is, a std::pair).
No iterators or references are invalidated.
[in] | k | the key used both to look up and to insert if not found. |
[in] | args | arguments to forward to the constructor of the element. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
auto pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::try_emplace | ( | K && | k, |
Args &&... | args | ||
) | -> typename std::enable_if< detail::has_is_transparent<BV>::value && !std::is_same<typename std::remove_const< typename std::remove_reference< K>::type>::type, key_type>::value, std::pair<iterator, bool>>::type |
If a key equivalent to k already exists in the container, does nothing.
Otherwise, behaves like emplace except that the element is constructed as value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<Args>(args)...)).
Unlike insert or emplace, this method do not move from rvalue arguments if the insertion does not happen, which makes it easy to manipulate maps whose values are move-only types. In addition, try_emplace treats the key and the arguments to the mapped_type separately, unlike emplace, which requires the arguments to construct a value_type (that is, a std::pair).
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | the key used both to look up and to insert if not found. |
[in] | args | arguments to forward to the constructor of the element. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
std::pair<typename radix_tree<Key, Value, BytesView, MtMode>::iterator, bool> pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::try_emplace | ( | key_type && | k, |
Args &&... | args | ||
) |
If a key equivalent to k already exists in the container, does nothing.
Otherwise, behaves like emplace except that the element is constructed as value_type(std::piecewise_construct, std::forward_as_tuple(std::move(k)), std::forward_as_tuple(std::forward<Args>(args)...)).
Unlike insert or emplace, this method do not move from rvalue arguments if the insertion does not happen, which makes it easy to manipulate maps whose values are move-only types. In addition, try_emplace treats the key and the arguments to the mapped_type separately, unlike emplace, which requires the arguments to construct a value_type (that is, a std::pair).
[in] | k | the key used both to look up and to insert if not found. |
[in] | args | arguments to forward to the constructor of the element. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
rethrows | constructor exception. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::upper_bound | ( | const K & | k | ) |
Returns an iterator pointing to the first element that is greater than key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::upper_bound | ( | const K & | k | ) | const |
Returns an iterator pointing to the first element that is greater than key.
This overload only participates in overload resolution if BytesView struct has a type member named is_transparent.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::upper_bound | ( | const key_type & | k | ) |
Returns an iterator pointing to the first element that is greater than key.
[in] | k | key value to compare the elements to. |
radix_tree< Key, Value, BytesView, MtMode >::const_iterator pmem::obj::experimental::radix_tree< Key, Value, BytesView, MtMode >::upper_bound | ( | const key_type & | k | ) | const |
Returns an iterator pointing to the first element that is greater than key.
[in] | k | key value to compare the elements to. |
|
private |
Checks if any node in the.
path | was modified. |