PMDK C++ bindings
1.9.1
This is the C++ bindings documentation for PMDK's libpmemobj.
|
pmem::obj::vector - persistent container with std::vector compatible interface. More...
#include <libpmemobj++/container/vector.hpp>
Public Member Functions | |
vector () | |
Default constructor. More... | |
vector (size_type count, const value_type &value) | |
Constructs the container with count copies of elements with value value. More... | |
vector (size_type count) | |
Constructs the container with count copies of T default constructed values. More... | |
template<typename InputIt , typename std::enable_if< detail::is_input_iterator< InputIt >::value, InputIt >::type * = nullptr> | |
vector (InputIt first, InputIt last) | |
Constructs the container with the contents of the range [first, last). More... | |
vector (const vector &other) | |
Copy constructor. More... | |
vector (vector &&other) | |
Move constructor. More... | |
vector (std::initializer_list< T > init) | |
Constructs the container with the contents of the initializer list init. More... | |
vector (const std::vector< T > &other) | |
Copy constructor. More... | |
vector & | operator= (const vector &other) |
Copy assignment operator. More... | |
vector & | operator= (vector &&other) |
Move assignment operator. More... | |
vector & | operator= (std::initializer_list< T > ilist) |
Replaces the contents with those identified by initializer list ilist transactionally. More... | |
vector & | operator= (const std::vector< T > &other) |
Copy assignment operator. More... | |
template<typename InputIt , typename std::enable_if< detail::is_input_iterator< InputIt >::value, InputIt >::type * = nullptr> | |
void | assign (InputIt first, InputIt last) |
Replaces the contents with copies of those in the range [first, last) transactionally. More... | |
void | assign (std::initializer_list< T > ilist) |
Replaces the contents with the elements from the initializer list ilist transactionally. More... | |
void | assign (const vector &other) |
Copy assignment method. More... | |
void | assign (vector &&other) |
Move assignment method. More... | |
void | assign (const std::vector< T > &other) |
Copy assignment method. More... | |
~vector () | |
Destructor. More... | |
reference | at (size_type n) |
Access element at specific index with bounds checking and add it to a transaction. More... | |
const_reference | at (size_type n) const |
Access element at specific index with bounds checking. More... | |
const_reference | const_at (size_type n) const |
Access element at specific index with bounds checking. More... | |
reference | operator[] (size_type n) |
Access element at specific index and add it to a transaction. More... | |
const_reference | operator[] (size_type n) const |
Access element at specific index. More... | |
reference | front () |
Access the first element and add this element to a transaction. More... | |
const_reference | front () const |
Access the first element. More... | |
const_reference | cfront () const |
Access the first element. More... | |
reference | back () |
Access the last element and add this element to a transaction. More... | |
const_reference | back () const |
Access the last element. More... | |
const_reference | cback () const |
Access the last element. More... | |
value_type * | data () |
Returns raw pointer to the underlying data and adds entire array to a transaction. More... | |
const value_type * | data () const noexcept |
Returns const raw pointer to the underlying data. More... | |
const value_type * | cdata () const noexcept |
Returns const raw pointer to the underlying data. More... | |
iterator | begin () |
Returns an iterator to the beginning. More... | |
const_iterator | begin () const noexcept |
Returns const iterator to the beginning. More... | |
const_iterator | cbegin () const noexcept |
Returns const iterator to the beginning. More... | |
iterator | end () |
Returns an iterator to past the end. More... | |
const_iterator | end () const noexcept |
Returns a const iterator to past the end. More... | |
const_iterator | cend () const noexcept |
Returns a const iterator to the end. More... | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the beginning. More... | |
const_reverse_iterator | rbegin () const noexcept |
Returns a const reverse iterator to the beginning. More... | |
const_reverse_iterator | crbegin () const noexcept |
Returns a const reverse iterator to the beginning. More... | |
reverse_iterator | rend () |
Returns a reverse iterator to the end. More... | |
const_reverse_iterator | rend () const noexcept |
Returns a const reverse iterator to the end. More... | |
const_reverse_iterator | crend () const noexcept |
Returns a const reverse iterator to the beginning. More... | |
slice< pointer > | range (size_type start, size_type n) |
Returns slice and snapshots requested range. More... | |
slice< range_snapshotting_iterator > | range (size_type start, size_type n, size_type snapshot_size) |
Returns slice. More... | |
slice< const_iterator > | range (size_type start, size_type n) const |
Returns const slice. More... | |
slice< const_iterator > | crange (size_type start, size_type n) const |
Returns const slice. More... | |
void | for_each_ptr (for_each_ptr_function func) |
Iterates over all internal pointers and executes a callback function on each of them. More... | |
constexpr bool | empty () const noexcept |
Checks whether the container is empty. More... | |
size_type | size () const noexcept |
constexpr size_type | max_size () const noexcept |
void | reserve (size_type capacity_new) |
Increases the capacity of the vector to capacity_new transactionally. More... | |
size_type | capacity () const noexcept |
void | shrink_to_fit () |
Requests transactional removal of unused capacity. More... | |
void | clear () |
Clears the content of a vector transactionally. More... | |
void | free_data () |
Clears the content of a vector and frees all allocated persistent memory for data transactionally. More... | |
iterator | insert (const_iterator pos, const T &value) |
Inserts value before pos in the container transactionally. More... | |
iterator | insert (const_iterator pos, T &&value) |
Moves value before pos in the container transactionally. More... | |
iterator | insert (const_iterator pos, size_type count, const T &value) |
Inserts count copies of the value before pos in the container transactionally. More... | |
template<typename InputIt , typename std::enable_if< detail::is_input_iterator< InputIt >::value, InputIt >::type * = nullptr> | |
iterator | insert (const_iterator pos, InputIt first, InputIt last) |
Inserts elements from range [first, last) before pos in the container transactionally. More... | |
iterator | insert (const_iterator pos, std::initializer_list< T > ilist) |
Inserts elements from initializer list ilist before pos in the container transactionally. More... | |
template<class... Args> | |
iterator | emplace (const_iterator pos, Args &&... args) |
Inserts a new element into the container directly before pos. More... | |
template<class... Args> | |
reference | emplace_back (Args &&... args) |
Appends a new element to the end of the container. More... | |
iterator | erase (const_iterator pos) |
Removes the element at pos. More... | |
iterator | erase (const_iterator first, const_iterator last) |
Removes the elements in the range [first, last). More... | |
void | push_back (const T &value) |
Appends the given element value to the end of the container transactionally. More... | |
void | push_back (T &&value) |
Appends the given element value to the end of the container transactionally. More... | |
void | pop_back () |
Removes the last element of the container transactionally. More... | |
void | resize (size_type count) |
Resizes the container to count elements transactionally. More... | |
void | resize (size_type count, const value_type &value) |
Resizes the container to contain count elements transactionally. More... | |
void | swap (vector &other) |
Exchanges the contents of the container with other transactionally. | |
template<typename T > | |
void | assign (size_type count, const_reference value) |
Replaces the contents with count copies of value value transactionally. More... | |
Private Member Functions | |
void | alloc (size_type size) |
Private helper function. More... | |
void | check_pmem () |
Private helper function. More... | |
void | check_tx_stage_work () |
Private helper function. More... | |
template<typename... Args> | |
void | construct_at_end (size_type count, Args &&... args) |
Private helper function. More... | |
template<typename InputIt , typename std::enable_if< detail::is_input_iterator< InputIt >::value, InputIt >::type * = nullptr> | |
void | construct_at_end (InputIt first, InputIt last) |
Private helper function. More... | |
void | dealloc () |
Private helper function. More... | |
pool_base | get_pool () const noexcept |
Private helper function. More... | |
template<typename InputIt > | |
void | internal_insert (size_type idx, InputIt first, InputIt last) |
Private helper function. More... | |
void | realloc (size_type size) |
Private helper function. More... | |
size_type | get_recommended_capacity (size_type at_least) const |
Private helper function. More... | |
void | shrink (size_type size_new) |
Private helper function. More... | |
void | add_data_to_tx (size_type idx_first, size_type num) |
Private helper function. More... | |
template<typename InputIt > | |
void | construct_or_assign (size_type idx, InputIt first, InputIt last) |
Private helper function. More... | |
void | move_elements_backward (pointer first, pointer last, pointer d_last) |
Private helper function. More... | |
pmem::obj::vector - persistent container with std::vector compatible interface.
pmem::obj::vector< T >::vector |
Default 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::vector< T >::vector | ( | size_type | count, |
const value_type & | value | ||
) |
Constructs the container with count copies of elements with value value.
[in] | count | number of elements to construct. |
[in] | value | value of all constructed elements. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
|
explicit |
Constructs the container with count copies of T default constructed values.
[in] | count | number of elements to construct. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::vector< T >::vector | ( | InputIt | first, |
InputIt | last | ||
) |
Constructs the container with the contents of the range [first, last).
The first and last arguments must satisfy InputIterator requirements. This overload only participates in overload resolution if InputIt satisfies InputIterator, to avoid ambiguity with the overload of count-value constructor.
[in] | first | first iterator. |
[in] | last | last iterator. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::vector< T >::vector | ( | const vector< T > & | other | ) |
Copy constructor.
Constructs the container with the copy of the contents of other.
[in] | other | reference to the vector to be copied. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::vector< T >::vector | ( | vector< T > && | other | ) |
Move constructor.
Constructs the container with the contents of other using move semantics. After the move, other is guaranteed to be empty().
[in] | other | rvalue reference to the vector 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::vector< T >::vector | ( | std::initializer_list< T > | init | ) |
Constructs the container with the contents of the initializer list init.
[in] | init | 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 for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::vector< T >::vector | ( | const std::vector< T > & | other | ) |
Copy constructor.
Constructs the container with the copy of the contents of std::vector<T> other. This constructor is not specified by STL standards.
[in] | other | reference to the vector to be copied. |
pmem::pool_error | if an object is not in persistent memory. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
pmem::transaction_scope_error | if constructor wasn't called in transaction. |
rethrows | element constructor exception. |
pmem::obj::vector< T >::~vector |
Destructor.
Note that free_data may throw an transaction_free_error when freeing underlying array failed. It is recommended to call free_data manually before object destruction.
rethrows | destructor exception. |
transaction_free_error | when freeing underlying array failed. |
|
private |
Private helper function.
Takes a “snapshot” of data in range [&_data[idx_first], &_data[idx_first + num])
[in] | idx_first | first index. |
[in] | num | number of elements to snapshot. |
pmem::transaction_error | when snapshotting failed. |
|
private |
Private helper function.
Must be called during transaction. Allocates memory for given number of elements.
[in] | capacity_new | capacity of new underlying array. |
std::length_error | if new size exceeds biggest possible pmem allocation. |
pmem::transaction_alloc_error | when allocating memory for underlying array in transaction failed. |
void pmem::obj::vector< T >::assign | ( | const std::vector< T > & | other | ) |
Copy assignment method.
Replaces the contents with a copy of the contents of std::vector<T> other transactionally. This method is not specified by STL standards.
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
void pmem::obj::vector< T >::assign | ( | const vector< T > & | other | ) |
Copy assignment method.
Replaces the contents with a copy of the contents of other transactionally. This method is not specified by STL standards.
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
void pmem::obj::vector< T >::assign | ( | InputIt | first, |
InputIt | last | ||
) |
Replaces the contents with copies of those in the range [first, last) transactionally.
This overload participates in overload resolution only if InputIt satisfies InputIterator. All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
[in] | first | first iterator. |
[in] | last | last iterator. |
std::length_error | if std::distance(first, last) > max_size(). |
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
void pmem::obj::vector< T >::assign | ( | size_type | count, |
const_reference | value | ||
) |
Replaces the contents with count copies of value value transactionally.
All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
[in] | count | number of elements to construct. |
[in] | value | value of all constructed elements. |
std::length_error | if count > max_size(). |
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
void pmem::obj::vector< T >::assign | ( | std::initializer_list< T > | ilist | ) |
Replaces the contents with the elements from the initializer list ilist transactionally.
All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
[in] | ilist | initializer list with content to be constructed. |
std::length_error | if std::distance(first, last) > max_size(). |
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
void pmem::obj::vector< T >::assign | ( | vector< T > && | other | ) |
Move assignment method.
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. This method is not specified by STL standards.
pmem::transaction_free_error | when freeing underlying array failed. |
vector< T >::reference pmem::obj::vector< T >::at | ( | size_type | n | ) |
Access element at specific index with bounds checking and add it to a transaction.
[in] | n | index number. |
std::out_of_range | if n is not within the range of the container. |
pmem::transaction_error | when adding the object to the transaction failed. |
vector< T >::const_reference pmem::obj::vector< T >::at | ( | size_type | n | ) | const |
Access element at specific index with bounds checking.
[in] | n | index number. |
std::out_of_range | if n is not within the range of the container. |
vector< T >::reference pmem::obj::vector< T >::back |
Access the last element and add this element to a transaction.
pmem::transaction_error | when adding the object to the transaction failed. |
vector< T >::const_reference pmem::obj::vector< T >::back |
Access the last element.
vector< T >::iterator pmem::obj::vector< T >::begin |
Returns an iterator to the beginning.
|
noexcept |
Returns const iterator to the beginning.
|
noexcept |
vector< T >::const_reference pmem::obj::vector< T >::cback |
|
noexcept |
|
noexcept |
|
noexcept |
vector< T >::const_reference pmem::obj::vector< T >::cfront |
|
private |
Private helper function.
Checks if vector resides on pmem and throws an exception if not.
pool_error | if vector 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::vector< T >::clear |
Clears the content of a vector transactionally.
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
vector< T >::const_reference pmem::obj::vector< T >::const_at | ( | size_type | n | ) | const |
Access element at specific index with bounds checking.
In contradiction to at(), const_at() will return const_reference not depending on the const-qualification of the object it is called on. std::vector doesn't provide const_at() method.
[in] | n | index number. |
std::out_of_range | if n is not within the range of the container. |
|
private |
Private helper function.
Must be called during transaction. Assumes that there is free space for additional elements and input arguments satisfy InputIterator requirements. Copies elements at index size() in underlying array with the contents of the range [first, last). This overload participates in overload resolution only if InputIt satisfies InputIterator.
[in] | first | first iterator. |
[in] | last | last iterator. |
rethrows | constructor exception. |
|
private |
Private helper function.
Must be called during transaction. Assumes that there is free space for additional elements. Constructs elements at index size() in underlying array based on given parameters.
[in] | count | number of elements to be constructed. |
[in] | args | variadic template arguments for value_type constructor. |
rethrows | constructor exception. |
|
private |
Private helper function.
It behaves similarly to std::move_backward but uses either copy constructor in case destination memory is not initialized or copy assignment operator otherwise.
slice< typename vector< T >::const_iterator > pmem::obj::vector< T >::crange | ( | size_type | start, |
size_type | n | ||
) | const |
Returns const slice.
This method is not specified by STL standards.
[in] | start | start index of requested range. |
[in] | n | number of elements in range. |
std::out_of_range | if any element of the range would be outside of the vector. |
|
noexcept |
|
noexcept |
Returns a const reverse iterator to the beginning.
In contradiction to rend(), crend() will return const_reverse_iterator not depending on the const-qualification of the object it is called on.
vector< T >::value_type * pmem::obj::vector< T >::data |
Returns raw pointer to the underlying data and adds entire array to a transaction.
pmem::transaction_error | when adding the object to the transaction failed. |
|
noexcept |
Returns const raw pointer to the underlying data.
|
private |
Private helper function.
Must be called during transaction. Deallocates underlying array.
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::iterator pmem::obj::vector< T >::emplace | ( | const_iterator | pos, |
Args &&... | args | ||
) |
Inserts a new element into the container directly before pos.
The element is constructed in-place. The arguments args... are forwarded to the constructor as std::forward<Args>(args).... If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated. Note that standard allows args to be a self reference and internal emplace implementation handles this case by creating temporary element_type object. This object is being stored either on stack or on pmem, see pmem::detail::temp_value for details.
[in] | pos | iterator before which the new element will be constructed. |
[in] | args | arguments to forward to the constructor of the element. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::reference pmem::obj::vector< T >::emplace_back | ( | Args &&... | args | ) |
Appends a new element to the end of the container.
The element is constructed in-place. The arguments args... are forwarded to the constructor as std::forward<Args>(args).... If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.
[in] | args | arguments to forward to the constructor of the element. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
|
constexprnoexcept |
Checks whether the container is empty.
vector< T >::iterator pmem::obj::vector< T >::end |
Returns an iterator to past the end.
|
noexcept |
Returns a const iterator to past the end.
vector< T >::iterator pmem::obj::vector< T >::erase | ( | const_iterator | first, |
const_iterator | last | ||
) |
Removes the elements in the range [first, last).
Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.
[in] | first | beginning of the range of elements to be removed. |
[in] | last | end of range of elements to be removed. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
vector< T >::iterator pmem::obj::vector< T >::erase | ( | const_iterator | pos | ) |
Removes the element at pos.
Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.
[in] | pos | iterator to the element to be removed. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
void pmem::obj::vector< T >::for_each_ptr | ( | for_each_ptr_function | func | ) |
Iterates over all internal pointers and executes a callback function on each of them.
In this implementation, it is just a single pointer.
func | callback function to call on internal pointer. |
void pmem::obj::vector< T >::free_data |
Clears the content of a vector and frees all allocated persistent memory for data transactionally.
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing underlying array failed. |
vector< T >::reference pmem::obj::vector< T >::front |
Access the first element and add this element to a transaction.
pmem::transaction_error | when adding the object to the transaction failed. |
vector< T >::const_reference pmem::obj::vector< T >::front |
Access the first element.
|
privatenoexcept |
Private helper function.
|
private |
Private helper function.
Returns recommended capacity for at least at_least elements.
vector< T >::iterator pmem::obj::vector< T >::insert | ( | const_iterator | pos, |
const T & | value | ||
) |
Inserts value before pos in the container transactionally.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
[in] | pos | iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | value | element value to be inserted. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::iterator pmem::obj::vector< T >::insert | ( | const_iterator | pos, |
InputIt | first, | ||
InputIt | last | ||
) |
Inserts elements from range [first, last) before pos in the container transactionally.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated. This overload participates in overload resolution only if InputIt qualifies as InputIterator, to avoid ambiguity with the pos-count-value overload. The behavior is undefined if first and last are iterators into *this.
[in] | pos | iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | first | begin of the range of elements to insert, can't be iterator into container for which insert is called. |
[in] | last | end of the range of elements to insert, can't be iterator into container for which insert is called. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::iterator pmem::obj::vector< T >::insert | ( | const_iterator | pos, |
size_type | count, | ||
const T & | value | ||
) |
Inserts count copies of the value before pos in the container transactionally.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
[in] | pos | iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | count | number of copies to be inserted. |
[in] | value | element value to be inserted. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::iterator pmem::obj::vector< T >::insert | ( | const_iterator | pos, |
std::initializer_list< T > | ilist | ||
) |
Inserts elements from initializer list ilist before pos in the container transactionally.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
[in] | pos | iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | ilist | initializer list to insert the values from. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::iterator pmem::obj::vector< T >::insert | ( | const_iterator | pos, |
T && | value | ||
) |
Moves value before pos in the container transactionally.
Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.
[in] | pos | iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | value | element value to be inserted. |
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
|
private |
Private helper function.
Must be called during transaction. Inserts a gap for count elements starting at index idx. If there is not enough space available, reallocation occurs with new recommended size. Range specified by first, last is then inserted into the gap.
param[in] idx index number where insert should be made param[in] first iterator to beginning of the range to insert param[in] last iterator to end of the range to insert
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
|
constexprnoexcept |
|
private |
Private helper function.
It behaves similarly to std::move_backward but uses either copy constructor in case destination memory is not initialized or copy assignment operator otherwise.
vector< T > & pmem::obj::vector< T >::operator= | ( | const std::vector< T > & | other | ) |
Copy assignment operator.
Replaces the contents with a copy of the contents of std::vector<T> other transactionally. This method is not specified by STL standards.
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
vector< T > & pmem::obj::vector< T >::operator= | ( | const vector< T > & | other | ) |
Copy assignment operator.
Replaces the contents with a copy of the contents of other transactionally.
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
vector< T > & pmem::obj::vector< T >::operator= | ( | std::initializer_list< T > | ilist | ) |
Replaces the contents with those identified by initializer list ilist transactionally.
std::length_error | if ilist.size() > max_size(). |
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
vector< T > & pmem::obj::vector< T >::operator= | ( | vector< T > && | 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::transaction_free_error | when freeing underlying array failed. |
vector< T >::reference pmem::obj::vector< T >::operator[] | ( | size_type | n | ) |
Access element at specific index and add it to a transaction.
No bounds checking is performed.
[in] | n | index number. |
pmem::transaction_error | when adding the object to the transaction failed. |
vector< T >::const_reference pmem::obj::vector< T >::operator[] | ( | size_type | n | ) | const |
Access element at specific index.
No bounds checking is performed.
[in] | n | index number. |
void pmem::obj::vector< T >::pop_back |
Removes the last element of the container transactionally.
Calling pop_back on an empty container does nothing. No iterators or references except for back() and end() are invalidated.
transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
void pmem::obj::vector< T >::push_back | ( | const T & | value | ) |
Appends the given element value to the end of the container transactionally.
The new element is initialized as a copy of value.
[in] | value | the value of the element to be appended. |
transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
void pmem::obj::vector< T >::push_back | ( | T && | value | ) |
Appends the given element value to the end of the container transactionally.
value is moved into the new element.
[in] | value | the value of the element to be appended. |
transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
slice< typename vector< T >::pointer > pmem::obj::vector< T >::range | ( | size_type | start, |
size_type | n | ||
) |
Returns slice and snapshots requested range.
This method is not specified by STL standards.
[in] | start | start index of requested range. |
[in] | n | number of elements in range. |
std::out_of_range | if any element of the range would be outside of the vector. |
pmem::transaction_error | when snapshotting failed. |
slice< typename vector< T >::const_iterator > pmem::obj::vector< T >::range | ( | size_type | start, |
size_type | n | ||
) | const |
Returns const slice.
This method is not specified by STL standards.
[in] | start | start index of requested range. |
[in] | n | number of elements in range. |
std::out_of_range | if any element of the range would be outside of the vector. |
slice< typename vector< T >::range_snapshotting_iterator > pmem::obj::vector< T >::range | ( | size_type | start, |
size_type | n, | ||
size_type | snapshot_size | ||
) |
Returns slice.
This method is not specified by STL standards.
[in] | start | start index of requested range. |
[in] | n | number of elements in range. |
[in] | snapshot_size | number of elements which should be snapshotted in a bulk while traversing this slice. If provided value is larger or equal to n, entire range is added to a transaction. If value is equal to 0 no snapshotting happens. |
std::out_of_range | if any element of the range would be outside of the vector. |
vector< T >::reverse_iterator pmem::obj::vector< T >::rbegin |
Returns a reverse iterator to the beginning.
|
noexcept |
Returns a const reverse iterator to the beginning.
|
private |
Private helper function.
Must be called during transaction. Allocates new memory for capacity_new number of elements and copies or moves old elements to new memory area. If the current size is greater than capacity_new, the container is reduced to its first capacity_new elements. If was never allocated behaves as an alloc call.
param[in] capacity_new new capacity.
pmem::transaction_error | when snapshotting failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_free_error | when freeing old underlying array failed. |
vector< T >::reverse_iterator pmem::obj::vector< T >::rend |
Returns a reverse iterator to the end.
|
noexcept |
Returns a const reverse iterator to the end.
void pmem::obj::vector< T >::reserve | ( | size_type | capacity_new | ) |
Increases the capacity of the vector to capacity_new transactionally.
If capacity_new is greater than the current capacity(), new storage is allocated, otherwise the method does nothing. If capacity_new is greater than capacity(), all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
[in] | capacity_new | new capacity. |
rethrows | destructor exception. |
std::length_error | if new_cap > max_size(). |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_alloc_error | when allocating new memory failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
void pmem::obj::vector< T >::resize | ( | size_type | count | ) |
Resizes the container to count elements transactionally.
If the current size is greater than count, the container is reduced to its first count elements. If the current size is less than count, additional default-inserted elements are appended.
[in] | count | new size of the container |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
void pmem::obj::vector< T >::resize | ( | size_type | count, |
const value_type & | value | ||
) |
Resizes the container to contain count elements transactionally.
If the current size is greater than count, the container is reduced to its first count elements. If the current size is less than count, additional copies of value are appended.
[in] | count | new size of the container. |
[in] | value | the value to initialize the new elements with. |
rethrows | constructor exception. |
rethrows | destructor exception. |
pmem::transaction_error | when snapshotting failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
|
private |
Private helper function.
Must be called during transaction. Destroys elements in underlying array beginning from position size_new.
[in] | size_new | new size |
pmem::transaction_error | when snapshotting failed. |
rethrows | destructor exception. |
void pmem::obj::vector< T >::shrink_to_fit |
Requests transactional removal of unused capacity.
New capacity will be set to current vector size. If reallocation occurs, all iterators, including the past the end iterator, and all references to the elements are invalidated. If no reallocation takes place, no iterators or references are invalidated.
pmem::transaction_error | when snapshotting failed |
pmem::transaction_alloc_error | when reallocating failed. |
pmem::transaction_free_error | when freeing old underlying array failed. |
rethrows | constructor exception. |
rethrows | destructor exception. |
|
noexcept |