9#ifndef LIBPMEMOBJ_SEGMENT_VECTOR_HPP
10#define LIBPMEMOBJ_SEGMENT_VECTOR_HPP
17#include <libpmemobj++/detail/temp_value.hpp>
35namespace segment_vector_internal
45template <
typename Container,
bool is_const>
49 using iterator_category = std::random_access_iterator_tag;
50 using difference_type = std::ptrdiff_t;
51 using table_type = Container;
52 using size_type =
typename table_type::size_type;
53 using value_type =
typename table_type::value_type;
56 typename std::conditional<is_const,
const table_type *,
59 typename std::conditional<is_const,
60 typename table_type::const_reference,
61 typename table_type::reference>::type;
63 typename std::conditional<is_const,
64 typename table_type::const_pointer,
65 typename table_type::pointer>::type;
85 template <
typename U = void,
86 typename =
typename std::enable_if<is_const, U>::type>
131template <
typename Container,
bool is_const>
133 : table(
nullptr), index()
141template <
typename Container,
bool is_const>
143 size_type idx) noexcept
144 : table(tab), index(idx)
152template <
typename Container,
bool is_const>
155 : table(other.table), index(other.index)
160template <
typename Container,
bool is_const>
161template <
typename U,
typename>
164 : table(other.table), index(other.index)
173template <
typename Container,
bool is_const>
186template <
typename Container,
bool is_const>
190 auto iterator = *
this;
200template <
typename Container,
bool is_const>
212template <
typename Container,
bool is_const>
216 index +=
static_cast<size_type
>(idx);
225template <
typename Container,
bool is_const>
238template <
typename Container,
bool is_const>
242 auto iterator = *
this;
252template <
typename Container,
bool is_const>
264template <
typename Container,
bool is_const>
268 index -=
static_cast<size_type
>(idx);
277template <
typename Container,
bool is_const>
279typename segment_iterator<Container, is_const>::difference_type
283 return static_cast<difference_type
>(index + rhs.index);
291template <
typename Container,
bool is_const>
293typename segment_iterator<Container, is_const>::difference_type
297 return static_cast<difference_type
>(index - rhs.index);
307template <
typename Container,
bool is_const>
313 return (table == rhs.table) && (index == rhs.index);
324template <
typename Container,
bool is_const>
330 return (table != rhs.table) || (index != rhs.index);
343template <
typename Container,
bool is_const>
349 if (table != rhs.table)
350 throw std::invalid_argument(
"segment_iterator::operator<");
352 return index < rhs.index;
366template <
typename Container,
bool is_const>
372 if (table != rhs.table)
373 throw std::invalid_argument(
"segment_iterator::operator>");
375 return index > rhs.index;
389template <
typename Container,
bool is_const>
395 if (table != rhs.table)
396 throw std::invalid_argument(
"segment_iterator::operator<=");
398 return index <= rhs.index;
412template <
typename Container,
bool is_const>
418 if (table != rhs.table)
419 throw std::invalid_argument(
"segment_iterator::operator>=");
421 return index >= rhs.index;
427template <
typename Container,
bool is_const>
428typename segment_iterator<Container, is_const>::reference
431 return table->operator[](index);
437template <
typename Container,
bool is_const>
438typename segment_iterator<Container, is_const>::pointer
456 segment_vector_internal::exponential_size_policy<
467template <
size_t SegmentSize = 1024,
471 SegmentType, SegmentSize>;
503template <
typename T,
typename Policy = exponential_size_vector_policy<>>
507 using policy_type = Policy;
508 using segment_type =
typename policy_type::template segment_type<T>;
509 using segment_vector_type =
510 typename policy_type::template segment_vector_type<T>;
512 using policy = policy_type;
513 using storage = policy_type;
516 using value_type = T;
517 using size_type = std::size_t;
518 using difference_type = std::ptrdiff_t;
519 using reference = value_type &;
520 using const_reference =
const value_type &;
521 using pointer = value_type *;
522 using const_pointer =
const value_type *;
528 using reverse_iterator = std::reverse_iterator<iterator>;
529 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
535 template <
typename InputIt,
536 typename std::enable_if<
538 InputIt>::type * =
nullptr>
552 void assign(size_type count, const_reference value);
553 template <
typename InputIt,
554 typename std::enable_if<
556 InputIt>::type * =
nullptr>
557 void assign(InputIt first, InputIt last);
558 void assign(std::initializer_list<T> ilist);
561 void assign(
const std::vector<T> &other);
567 reference
at(size_type n);
568 const_reference
at(size_type n)
const;
587 const_reverse_iterator
rbegin() const noexcept;
588 const_reverse_iterator
crbegin() const noexcept;
590 const_reverse_iterator
rend() const noexcept;
591 const_reverse_iterator
crend() const noexcept;
599 constexpr
bool empty() const noexcept;
600 size_type
size() const noexcept;
612 template <typename InputIt,
613 typename std::enable_if<
614 detail::is_input_iterator<InputIt>::value,
615 InputIt>::type * =
nullptr>
618 template <class... Args>
620 template <class... Args>
628 void resize(size_type count, const value_type &value);
634 template <typename... Args>
635 void construct(size_type idx, size_type count, Args &&... args);
636 template <typename InputIt,
637 typename std::enable_if<
638 detail::is_input_iterator<InputIt>::value,
639 InputIt>::type * =
nullptr>
647 reference
get(size_type n);
648 const_reference
get(size_type n) const;
649 const_reference
cget(size_type n) const;
653 p<size_type> _segments_used = 0;
655 segment_vector_type _data;
659template <typename T, typename Policy>
667template <typename T, typename Policy>
670template <typename T, typename Policy>
673template <typename T, typename Policy>
676template <typename T, typename Policy>
679template <typename T, typename Policy>
682template <typename T, typename Policy>
691template <typename T, typename Policy>
693 const std::
vector<T> &rhs);
694template <typename T, typename Policy>
696 const std::
vector<T> &rhs);
697template <typename T, typename Policy>
699template <typename T, typename Policy>
701 const std::
vector<T> &rhs);
702template <typename T, typename Policy>
704template <typename T, typename Policy>
706 const std::
vector<T> &rhs);
712template <typename T, typename Policy>
713bool operator==(const std::
vector<T> &lhs,
715template <typename T, typename Policy>
716bool operator!=(const std::
vector<T> &lhs,
718template <typename T, typename Policy>
720template <typename T, typename Policy>
721bool operator<=(const std::
vector<T> &lhs,
723template <typename T, typename Policy>
725template <typename T, typename Policy>
726bool operator>=(const std::
vector<T> &lhs,
737template <typename T, typename Policy>
764template <
typename T,
typename Policy>
766 const value_type &value)
793template <
typename T,
typename Policy>
826template <
typename T,
typename Policy>
827template <
typename InputIt,
828 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
857template <
typename T,
typename Policy>
884template <
typename T,
typename Policy>
887 _data = std::move(other._data);
888 _segments_used = other._segments_used;
889 other._segments_used = 0;
913template <
typename T,
typename Policy>
940template <
typename T,
typename Policy>
963template <
typename T,
typename Policy>
986template <
typename T,
typename Policy>
990 assign(std::move(other));
1011template <
typename T,
typename Policy>
1015 assign(ilist.begin(), ilist.end());
1036template <
typename T,
typename Policy>
1066template <
typename T,
typename Policy>
1070 if (count > max_size())
1071 throw std::length_error(
"Assignable range exceeds max size.");
1075 if (count > capacity())
1076 internal_reserve(count);
1077 else if (count < size())
1085 size_type
end = policy::get_segment(count - 1);
1086 for (size_type i = 0; i <
end; ++i)
1087 _data[i].assign(policy::segment_size(i), value);
1088 _data[
end].assign(count - policy::segment_top(
end),
1091 _segments_used =
end + 1;
1094 assert(segment_capacity_validation());
1119template <
typename T,
typename Policy>
1120template <
typename InputIt,
1121 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
1126 size_type count =
static_cast<size_type
>(std::distance(first, last));
1127 if (count > max_size())
1128 throw std::length_error(
"Assignable range exceeds max size.");
1132 if (count > capacity())
1133 internal_reserve(count);
1134 else if (count < size())
1142 difference_type num;
1143 size_type
end = policy::get_segment(count - 1);
1144 for (size_type i = 0; i <
end; ++i) {
1145 size_type size = policy::segment_size(i);
1146 num =
static_cast<difference_type
>(size);
1147 _data[i].assign(first, std::next(first, num));
1148 std::advance(first, num);
1150 num =
static_cast<difference_type
>(
1151 std::distance(first, last));
1152 _data[
end].assign(first, std::next(first, num));
1154 _segments_used =
end + 1;
1157 assert(segment_capacity_validation());
1180template <
typename T,
typename Policy>
1184 assign(ilist.begin(), ilist.end());
1203template <
typename T,
typename Policy>
1226template <
typename T,
typename Policy>
1235 _data = std::move(other._data);
1236 _segments_used = other._segments_used;
1237 other._segments_used = 0;
1257template <
typename T,
typename Policy>
1261 assign(other.cbegin(), other.cend());
1271template <
typename T,
typename Policy>
1294template <
typename T,
typename Policy>
1295typename segment_vector<T, Policy>::reference
1299 throw std::out_of_range(
"segment_vector::at");
1301 detail::conditional_add_to_tx(&
get(n), 1, POBJ_XADD_ASSUME_INITIALIZED);
1316template <
typename T,
typename Policy>
1317typename segment_vector<T, Policy>::const_reference
1321 throw std::out_of_range(
"segment_vector::at");
1337template <
typename T,
typename Policy>
1338typename segment_vector<T, Policy>::const_reference
1342 throw std::out_of_range(
"segment_vector::const_at");
1357template <
typename T,
typename Policy>
1358typename segment_vector<T, Policy>::reference
1361 reference element =
get(n);
1363 detail::conditional_add_to_tx(&element, 1,
1364 POBJ_XADD_ASSUME_INITIALIZED);
1376template <
typename T,
typename Policy>
1377typename segment_vector<T, Policy>::const_reference
1391template <
typename T,
typename Policy>
1392typename segment_vector<T, Policy>::reference
1395 detail::conditional_add_to_tx(&_data[0][0], 1,
1396 POBJ_XADD_ASSUME_INITIALIZED);
1406template <
typename T,
typename Policy>
1407typename segment_vector<T, Policy>::const_reference
1420template <
typename T,
typename Policy>
1421typename segment_vector<T, Policy>::const_reference
1435template <
typename T,
typename Policy>
1436typename segment_vector<T, Policy>::reference
1439 reference element =
get(size() - 1);
1441 detail::conditional_add_to_tx(&element, 1,
1442 POBJ_XADD_ASSUME_INITIALIZED);
1452template <
typename T,
typename Policy>
1453typename segment_vector<T, Policy>::const_reference
1456 return get(size() - 1);
1466template <
typename T,
typename Policy>
1467typename segment_vector<T, Policy>::const_reference
1470 return get(size() - 1);
1478template <
typename T,
typename Policy>
1491template <
typename T,
typename Policy>
1506template <
typename T,
typename Policy>
1519template <
typename T,
typename Policy>
1532template <
typename T,
typename Policy>
1547template <
typename T,
typename Policy>
1560template <
typename T,
typename Policy>
1561typename segment_vector<T, Policy>::reverse_iterator
1564 return reverse_iterator(
end());
1573template <
typename T,
typename Policy>
1574typename segment_vector<T, Policy>::const_reverse_iterator
1577 return const_reverse_iterator(
end());
1588template <
typename T,
typename Policy>
1589typename segment_vector<T, Policy>::const_reverse_iterator
1601template <
typename T,
typename Policy>
1602typename segment_vector<T, Policy>::reverse_iterator
1605 return reverse_iterator(
begin());
1614template <
typename T,
typename Policy>
1615typename segment_vector<T, Policy>::const_reverse_iterator
1618 return const_reverse_iterator(
begin());
1629template <
typename T,
typename Policy>
1630typename segment_vector<T, Policy>::const_reverse_iterator
1649template <
typename T,
typename Policy>
1653 if (start + n > size())
1654 throw std::out_of_range(
"segment_vector::range");
1656 snapshot_data(start, start + n);
1672template <
typename T,
typename Policy>
1676 if (start + n > size())
1677 throw std::out_of_range(
"segment_vector::range");
1693template <
typename T,
typename Policy>
1697 if (start + n > size())
1698 throw std::out_of_range(
"segment_vector::range");
1708template <
typename T,
typename Policy>
1718template <
typename T,
typename Policy>
1719typename segment_vector<T, Policy>::size_type
1722 size_type result = 0;
1725 for (size_type i = 0; i < _segments_used; ++i)
1726 result += _data.const_at(i).size();
1727 }
catch (std::out_of_range &) {
1739template <
typename T,
typename Policy>
1740constexpr typename segment_vector<T, Policy>::size_type
1743 return policy::max_size(_data);
1762template <
typename T,
typename Policy>
1766 if (capacity_new <= capacity())
1777template <
typename T,
typename Policy>
1778typename segment_vector<T, Policy>::size_type
1781 if (_segments_used == 0)
1783 return policy::capacity(_segments_used - 1);
1797template <
typename T,
typename Policy>
1803 size_type new_last = policy::get_segment(size() - 1);
1804 if (_segments_used - 1 == new_last)
1809 for (size_type i = new_last + 1; i < _segments_used; ++i)
1810 _data[i].free_data();
1811 _segments_used = new_last + 1;
1812 storage::resize(_data, _segments_used);
1827template <
typename T,
typename Policy>
1833 assert(segment_capacity_validation());
1848template <
typename T,
typename Policy>
1854 for (size_type i = 0; i < _segments_used; ++i)
1855 _data[i].free_data();
1883template <
typename T,
typename Policy>
1887 return insert(pos, 1, value);
1913template <
typename T,
typename Policy>
1917 size_type idx =
static_cast<size_type
>(pos -
cbegin());
1922 get(idx) = std::move(value);
1954template <
typename T,
typename Policy>
1959 size_type idx =
static_cast<size_type
>(pos -
cbegin());
1963 insert_gap(idx, count);
1964 for (size_type i = idx; i < idx + count; ++i)
1965 get(i) = std::move(value);
2004template <
typename T,
typename Policy>
2005template <
typename InputIt,
2006 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
2012 size_type idx =
static_cast<size_type
>(pos -
cbegin());
2013 size_type gap_size =
static_cast<size_type
>(std::distance(first, last));
2017 insert_gap(idx, gap_size);
2018 for (size_type i = idx; i < idx + gap_size; ++i, ++first)
2051template <
typename T,
typename Policy>
2054 std::initializer_list<T> ilist)
2056 return insert(pos, ilist.begin(), ilist.end());
2087template <
typename T,
typename Policy>
2088template <
class... Args>
2092 size_type idx =
static_cast<size_type
>(pos -
cbegin());
2096 detail::temp_value<value_type,
2097 noexcept(T(std::forward<Args>(args)...))>
2098 tmp(std::forward<Args>(args)...);
2100 get(idx) = std::move(tmp.get());
2130template <
typename T,
typename Policy>
2131template <
class... Args>
2132typename segment_vector<T, Policy>::reference
2135 assert(size() < max_size());
2139 if (size() == capacity())
2140 internal_reserve(capacity() + 1);
2142 size_type segment = policy::get_segment(size());
2143 _data[segment].emplace_back(std::forward<Args>(args)...);
2170template <
typename T,
typename Policy>
2174 return erase(pos, pos + 1);
2201template <
typename T,
typename Policy>
2205 size_type count =
static_cast<size_type
>(std::distance(first, last));
2206 size_type idx =
static_cast<size_type
>(first -
cbegin());
2213 size_type _size = size();
2215 if (!std::is_trivially_destructible<T>::value ||
2216 idx + count < _size)
2217 snapshot_data(idx, _size);
2228 size_type middle = policy::get_segment(_size - count);
2229 size_type last = policy::get_segment(_size - 1);
2230 size_type middle_size = policy::index_in_segment(_size - count);
2231 for (size_type s = last; s > middle; --s)
2233 _data[middle].resize(middle_size);
2235 _segments_used = middle + 1;
2238 assert(segment_capacity_validation());
2261template <
typename T,
typename Policy>
2265 emplace_back(value);
2286template <
typename T,
typename Policy>
2290 emplace_back(std::move(value));
2306template <
typename T,
typename Policy>
2315 assert(segment_capacity_validation());
2341template <
typename T,
typename Policy>
2347 size_type _size = size();
2351 if (capacity() < count)
2352 internal_reserve(count);
2353 construct(_size, count - _size);
2356 assert(segment_capacity_validation());
2383template <
typename T,
typename Policy>
2389 size_type _size = size();
2393 if (capacity() < count)
2394 internal_reserve(count);
2395 construct(_size, count - _size, value);
2398 assert(segment_capacity_validation());
2404template <
typename T,
typename Policy>
2410 _data.swap(other._data);
2411 std::swap(_segments_used, other._segments_used);
2430template <
typename T,
typename Policy>
2434 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2436 if (new_capacity > max_size())
2437 throw std::length_error(
"New capacity exceeds max size.");
2439 if (new_capacity == 0)
2442 size_type old_idx = policy::get_segment(capacity());
2443 size_type new_idx = policy::get_segment(new_capacity - 1);
2444 storage::resize(_data, new_idx + 1);
2445 for (size_type i = old_idx; i <= new_idx; ++i) {
2446 size_type segment_capacity = policy::segment_size(i);
2447 _data[i].reserve(segment_capacity);
2449 _segments_used = new_idx + 1;
2451 assert(segment_capacity_validation());
2480template <
typename T,
typename Policy>
2481template <
typename... Args>
2486 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2487 assert(capacity() >= size() + count);
2489 for (size_type i = idx; i < idx + count; ++i) {
2490 size_type segment = policy::get_segment(i);
2491 _data[segment].emplace_back(std::forward<Args>(args)...);
2494 assert(segment_capacity_validation());
2527template <
typename T,
typename Policy>
2528template <
typename InputIt,
2529 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
2535 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2536 size_type count =
static_cast<size_type
>(std::distance(first, last));
2537 assert(capacity() >= size() + count);
2539 for (size_type i = idx; i < idx + count; ++i, ++first) {
2540 size_type segment = policy::get_segment(i);
2541 _data[segment].emplace_back(*first);
2544 assert(segment_capacity_validation());
2568template <
typename T,
typename Policy>
2572 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2576 size_type _size = size();
2578 if (capacity() < _size + count)
2579 internal_reserve(_size + count);
2585 snapshot_data(idx, _size);
2587 resize(_size + count);
2588 std::move_backward(
begin,
end, dest);
2590 assert(segment_capacity_validation());
2612template <
typename T,
typename Policy>
2616 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2617 assert(size_new <= size());
2622 if (!std::is_trivially_destructible<T>::value)
2623 snapshot_data(size_new, size());
2625 size_type
begin = policy::get_segment(size() - 1);
2626 size_type
end = policy::get_segment(size_new);
2628 _data[
begin].clear();
2630 size_type residue = policy::index_in_segment(size_new);
2633 assert(segment_capacity_validation());
2643template <
typename T,
typename Policy>
2659template <
typename T,
typename Policy>
2666 size_type segment = policy::get_segment(first);
2667 size_type
end = policy::get_segment(last - 1);
2668 size_type count = policy::segment_top(segment + 1) - first;
2670 while (segment !=
end) {
2671 detail::conditional_add_to_tx(&cget(first), count,
2672 POBJ_XADD_ASSUME_INITIALIZED);
2673 first = policy::segment_top(++segment);
2674 count = policy::segment_size(segment);
2676 detail::conditional_add_to_tx(&cget(first), last - first,
2677 POBJ_XADD_ASSUME_INITIALIZED);
2685template <
typename T,
typename Policy>
2686typename segment_vector<T, Policy>::reference
2689 size_type s_idx = policy::get_segment(n);
2690 size_type local_idx = policy::index_in_segment(n);
2692 return _data[s_idx][local_idx];
2700template <
typename T,
typename Policy>
2701typename segment_vector<T, Policy>::const_reference
2704 size_type s_idx = policy::get_segment(n);
2705 size_type local_idx = policy::index_in_segment(n);
2707 return _data[s_idx][local_idx];
2715template <
typename T,
typename Policy>
2716typename segment_vector<T, Policy>::const_reference
2719 size_type s_idx = policy::get_segment(n);
2720 size_type local_idx = policy::index_in_segment(n);
2722 return _data[s_idx][local_idx];
2732template <
typename T,
typename Policy>
2736 for (size_type i = 0; i < _segments_used; ++i)
2737 if (_data.const_at(i).capacity() != policy::segment_size(i))
2748template <
typename T,
typename Policy>
2769template <
typename T,
typename Policy>
2793template <
typename T,
typename Policy>
2798 return !(lhs == rhs);
2813template <
typename T,
typename Policy>
2818 return std::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(),
2834template <
typename T,
typename Policy>
2839 return !(rhs < lhs);
2854template <
typename T,
typename Policy>
2874template <
typename T,
typename Policy>
2879 return !(lhs < rhs);
2895template <
typename T,
typename Policy>
2899 return lhs.
size() == rhs.size() &&
2900 std::equal(lhs.
begin(), lhs.
end(), rhs.begin());
2916template <
typename T,
typename Policy>
2920 return !(lhs == rhs);
2934template <
typename T,
typename Policy>
2938 return std::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.begin(),
2953template <
typename T,
typename Policy>
2957 return !(std::lexicographical_compare(rhs.begin(), rhs.end(),
2973template <
typename T,
typename Policy>
2977 return !(lhs <= rhs);
2991template <
typename T,
typename Policy>
2995 return !(lhs < rhs);
3011template <
typename T,
typename Policy>
3031template <
typename T,
typename Policy>
3035 return !(lhs == rhs);
3049template <
typename T,
typename Policy>
3067template <
typename T,
typename Policy>
3071 return !(rhs < lhs);
3086template <
typename T,
typename Policy>
3104template <
typename T,
typename Policy>
3108 return !(lhs < rhs);
Array container with std::array compatible interface.
static void run(obj::pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:823
Resides on pmem class.
Definition: p.hpp:35
The non-template pool base class.
Definition: pool.hpp:50
Iterator for segment_vector.
Definition: segment_vector.hpp:46
segment_iterator & operator-=(difference_type idx)
Random access decrementing with assignment.
Definition: segment_vector.hpp:266
segment_iterator operator-(difference_type idx) const
Random access decrementing.
Definition: segment_vector.hpp:254
bool operator==(const segment_iterator< Container, C > &rhs) const
Compare methods Template parameter is needed to enable this methods work with non-constant and consta...
Definition: segment_vector.hpp:310
segment_iterator() noexcept
Default constructor.
Definition: segment_vector.hpp:132
bool operator<=(const segment_iterator< Container, C > &rhs) const
Less or equal operator.
Definition: segment_vector.hpp:392
bool operator>(const segment_iterator< Container, C > &rhs) const
Greater operator.
Definition: segment_vector.hpp:369
pointer operator->() const
Member access.
Definition: segment_vector.hpp:439
bool operator<(const segment_iterator< Container, C > &rhs) const
Less operator.
Definition: segment_vector.hpp:346
segment_iterator operator+(difference_type idx) const
Random access incrementing.
Definition: segment_vector.hpp:202
segment_iterator & operator--()
Prefix decrement.
Definition: segment_vector.hpp:227
reference operator*() const
Indirection (dereference).
Definition: segment_vector.hpp:429
segment_iterator & operator++()
Prefix increment.
Definition: segment_vector.hpp:175
bool operator!=(const segment_iterator< Container, C > &rhs) const
Not equal operator.
Definition: segment_vector.hpp:327
segment_iterator & operator+=(difference_type idx)
Random access incrementing with assignment.
Definition: segment_vector.hpp:214
bool operator>=(const segment_iterator< Container, C > &rhs) const
Greater or equal operator.
Definition: segment_vector.hpp:415
A persistent version of segment vector implementation.
Definition: segment_vector.hpp:504
reference front()
Access the first element and add this element to a transaction.
Definition: segment_vector.hpp:1393
void reserve(size_type capacity_new)
Increases the capacity of the segment_vector to capacity_new transactionally.
Definition: segment_vector.hpp:1764
void assign(InputIt first, InputIt last)
Replaces the contents with copies of those in the range [first, last) transactionally.
Definition: segment_vector.hpp:1124
constexpr bool empty() const noexcept
Checks whether the container is empty.
Definition: segment_vector.hpp:1710
const_reverse_iterator crbegin() const noexcept
Returns a const reverse iterator to the beginning.
Definition: segment_vector.hpp:1590
segment_vector(InputIt first, InputIt last)
Constructs the container with the contents of the range [first, last).
Definition: segment_vector.hpp:830
size_type capacity() const noexcept
Definition: segment_vector.hpp:1779
void assign(std::initializer_list< T > ilist)
Replaces the contents with the elements from the initializer list ilist transactionally.
Definition: segment_vector.hpp:1182
pool_base get_pool() const
Private helper function.
Definition: segment_vector.hpp:2645
void assign(segment_vector &&other)
Move assignment method.
Definition: segment_vector.hpp:1228
reference get(size_type n)
Private helper function.
Definition: segment_vector.hpp:2687
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition: segment_vector.hpp:1562
constexpr size_type max_size() const noexcept
Definition: segment_vector.hpp:1741
reference emplace_back(Args &&... args)
Appends a new element to the end of the container transactionally.
Definition: segment_vector.hpp:2133
segment_vector(size_type count)
Constructs the container with count copies of T default constructed values.
Definition: segment_vector.hpp:794
const_reference at(size_type n) const
Access element at specific index with bounds checking.
Definition: segment_vector.hpp:1318
reference at(size_type n)
Access element at specific index with bounds checking and add it to a transaction.
Definition: segment_vector.hpp:1296
reference operator[](size_type n)
Access element at specific index and add it to a transaction.
Definition: segment_vector.hpp:1359
const_reference cfront() const
Access the first element.
Definition: segment_vector.hpp:1422
segment_vector(const std::vector< T > &other)
Copy constructor.
Definition: segment_vector.hpp:941
void swap(segment_vector &other)
Exchanges the contents of the container with other transactionally.
Definition: segment_vector.hpp:2406
void snapshot_data(size_type idx_first, size_type idx_last)
Private helper function.
Definition: segment_vector.hpp:2661
void clear()
Clears the content of a segment_vector transactionally.
Definition: segment_vector.hpp:1829
const_reference operator[](size_type n) const
Access element at specific index.
Definition: segment_vector.hpp:1378
~segment_vector()
Destructor.
Definition: segment_vector.hpp:1272
const_reference const_at(size_type n) const
Access element at specific index with bounds checking.
Definition: segment_vector.hpp:1339
const_reference cback() const
Access the last element.
Definition: segment_vector.hpp:1468
void assign(const std::vector< T > &other)
Copy assignment method.
Definition: segment_vector.hpp:1259
iterator begin()
Returns an iterator to the beginning.
Definition: segment_vector.hpp:1480
void resize(size_type count)
Resizes the container to count elements transactionally.
Definition: segment_vector.hpp:2343
const_iterator begin() const noexcept
Returns const iterator to the beginning.
Definition: segment_vector.hpp:1493
reference back()
Access the last element and add this element to a transaction.
Definition: segment_vector.hpp:1437
segment_vector(size_type count, const value_type &value)
Constructs the container with count copies of elements with value value.
Definition: segment_vector.hpp:765
const_reverse_iterator crend() const noexcept
Returns a const reverse iterator to the beginning.
Definition: segment_vector.hpp:1631
const_reference back() const
Access the last element.
Definition: segment_vector.hpp:1454
void push_back(const T &value)
Appends the given element value to the end of the container transactionally.
Definition: segment_vector.hpp:2263
const_reference front() const
Access the first element.
Definition: segment_vector.hpp:1408
slice< iterator > range(size_type start, size_type n)
Returns slice and snapshots requested range.
Definition: segment_vector.hpp:1651
size_type size() const noexcept
Definition: segment_vector.hpp:1720
void shrink(size_type size_new)
Private helper function.
Definition: segment_vector.hpp:2614
void assign(const segment_vector &other)
Copy assignment method.
Definition: segment_vector.hpp:1205
void free_data()
Clears the content of a segment_vector and frees all allocated persistent memory for data transaction...
Definition: segment_vector.hpp:1850
segment_vector & operator=(segment_vector &&other)
Move assignment operator.
Definition: segment_vector.hpp:988
iterator erase(const_iterator pos)
Removes the element at pos.
Definition: segment_vector.hpp:2172
const_reference cget(size_type n) const
Private helper function.
Definition: segment_vector.hpp:2717
segment_vector(const segment_vector &other)
Copy constructor.
Definition: segment_vector.hpp:858
iterator emplace(const_iterator pos, Args &&... args)
Inserts a new element into the container directly before pos.
Definition: segment_vector.hpp:2090
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition: segment_vector.hpp:1603
segment_vector()
Default constructor.
Definition: segment_vector.hpp:738
segment_vector & operator=(const segment_vector &other)
Copy assignment operator.
Definition: segment_vector.hpp:965
void internal_reserve(size_type new_capacity)
Private helper method.
Definition: segment_vector.hpp:2432
iterator end()
Returns an iterator to past the end.
Definition: segment_vector.hpp:1521
void pop_back()
Removes the last element of the container transactionally.
Definition: segment_vector.hpp:2308
void shrink_to_fit()
Requests transactional removal of unused capacity.
Definition: segment_vector.hpp:1799
void construct(size_type idx, size_type count, Args &&... args)
Private helper function.
Definition: segment_vector.hpp:2483
iterator insert(const_iterator pos, const T &value)
Inserts value before pos in the container transactionally.
Definition: segment_vector.hpp:1885
const_iterator cend() const noexcept
Returns a const iterator to the end.
Definition: segment_vector.hpp:1549
segment_vector & operator=(std::initializer_list< T > ilist)
Replaces the contents with those identified by initializer list ilist transactionally.
Definition: segment_vector.hpp:1013
slice< const_iterator > crange(size_type start, size_type n) const
Returns const slice.
Definition: segment_vector.hpp:1695
void insert_gap(size_type idx, size_type count)
Private helper function.
Definition: segment_vector.hpp:2570
segment_vector & operator=(const std::vector< T > &other)
Copy assignment operator.
Definition: segment_vector.hpp:1038
void construct_range(size_type idx, InputIt first, InputIt last)
Private helper function.
Definition: segment_vector.hpp:2532
bool segment_capacity_validation() const
Private helper function.
Definition: segment_vector.hpp:2734
void assign(size_type count, const_reference value)
Replaces the contents with count copies of value value transactionally.
Definition: segment_vector.hpp:1068
segment_vector(std::initializer_list< T > init)
Constructs the container with the contents of the initializer list init.
Definition: segment_vector.hpp:914
segment_vector(segment_vector &&other)
Move constructor.
Definition: segment_vector.hpp:885
const_iterator cbegin() const noexcept
Returns const iterator to the beginning.
Definition: segment_vector.hpp:1508
pmem::obj::slice - provides interface to access sequence of objects.
Definition: slice.hpp:50
pmem::obj::vector - persistent container with std::vector compatible interface.
Definition: vector.hpp:41
Commonly used functionality.
Functions for destroying arrays.
Persistent_ptr transactional allocation functions for objects.
bool operator<=(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less or equal operator.
Definition: array.hpp:779
pmem::obj::array< T, N >::const_iterator cend(const pmem::obj::array< T, N > &a)
Non-member cend.
Definition: array.hpp:799
pmem::obj::array< T, N >::reverse_iterator rend(pmem::obj::array< T, N > &a)
Non-member rend.
Definition: array.hpp:889
pmem::obj::array< T, N >::iterator end(pmem::obj::array< T, N > &a)
Non-member end.
Definition: array.hpp:849
pmem::obj::array< T, N >::reverse_iterator rbegin(pmem::obj::array< T, N > &a)
Non-member rbegin.
Definition: array.hpp:869
bool operator<(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less than operator.
Definition: array.hpp:748
T & get(pmem::obj::array< T, N > &a)
Non-member get function.
Definition: array.hpp:919
bool operator>=(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member greater or equal operator.
Definition: array.hpp:769
segment_vector_internal::exponential_size_policy< pmem::obj::vector, SegmentType > exponential_size_vector_policy
Exponential size policy with pmemobj vector as a type of segment vector, so this is a dynamic vector ...
Definition: segment_vector.hpp:484
bool operator!=(const allocator< T, P, Tr > &lhs, const OtherAllocator &rhs)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:536
segment_vector_internal::fixed_size_policy< pmem::obj::vector, SegmentType, SegmentSize > fixed_size_vector_policy
Fixed size policy with pmemobj vector of a given size as a type of segment vector,...
Definition: segment_vector.hpp:471
segment_vector_internal::exponential_size_policy< segment_vector_internal::array_64, SegmentType > exponential_size_array_policy
Exponential size policy with pmemobj array of size 64 as a type of segment vector,...
Definition: segment_vector.hpp:457
pool_base pool_by_vptr(const T *that)
Retrieve pool handle for the given pointer.
Definition: utils.hpp:32
bool operator==(standard_alloc_policy< T > const &, standard_alloc_policy< T2 > const &)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:420
bool operator>(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member greater than operator.
Definition: array.hpp:759
pmem::obj::array< T, N >::const_iterator cbegin(const pmem::obj::array< T, N > &a)
Non-member cbegin.
Definition: array.hpp:789
pmem::obj::array< T, N >::iterator begin(pmem::obj::array< T, N > &a)
Non-member begin.
Definition: array.hpp:829
void swap(pmem::obj::array< T, N > &lhs, pmem::obj::array< T, N > &rhs)
Non-member swap function.
Definition: array.hpp:909
Persistent memory namespace.
Definition: allocation_flag.hpp:15
Persistent smart pointer.
Convenience extensions for the resides on pmem property template.
A persistent version of segment vector implementation.
pmem::obj::array - persistent container with std::array compatible interface.
Definition: array.hpp:56
Commonly used SFINAE helpers.
C++ pmemobj transactions.
Vector container with std::vector compatible interface.