9 #ifndef LIBPMEMOBJ_SEGMENT_VECTOR_HPP
10 #define LIBPMEMOBJ_SEGMENT_VECTOR_HPP
35 namespace segment_vector_internal
45 template <
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>
131 template <
typename Container,
bool is_const>
133 : table(
nullptr), index()
141 template <
typename Container,
bool is_const>
143 size_type idx) noexcept
144 : table(tab), index(idx)
152 template <
typename Container,
bool is_const>
155 : table(other.table), index(other.index)
160 template <
typename Container,
bool is_const>
161 template <
typename U,
typename>
164 : table(other.table), index(other.index)
173 template <
typename Container,
bool is_const>
186 template <
typename Container,
bool is_const>
190 auto iterator = *
this;
200 template <
typename Container,
bool is_const>
212 template <
typename Container,
bool is_const>
216 index +=
static_cast<size_type
>(idx);
225 template <
typename Container,
bool is_const>
238 template <
typename Container,
bool is_const>
242 auto iterator = *
this;
252 template <
typename Container,
bool is_const>
264 template <
typename Container,
bool is_const>
268 index -=
static_cast<size_type
>(idx);
277 template <
typename Container,
bool is_const>
279 typename segment_iterator<Container, is_const>::difference_type
283 return static_cast<difference_type
>(index + rhs.index);
291 template <
typename Container,
bool is_const>
293 typename segment_iterator<Container, is_const>::difference_type
297 return static_cast<difference_type
>(index - rhs.index);
307 template <
typename Container,
bool is_const>
313 return (table == rhs.table) && (index == rhs.index);
324 template <
typename Container,
bool is_const>
330 return (table != rhs.table) || (index != rhs.index);
343 template <
typename Container,
bool is_const>
349 if (table != rhs.table)
350 throw std::invalid_argument(
"segment_iterator::operator<");
352 return index < rhs.index;
366 template <
typename Container,
bool is_const>
372 if (table != rhs.table)
373 throw std::invalid_argument(
"segment_iterator::operator>");
375 return index > rhs.index;
389 template <
typename Container,
bool is_const>
395 if (table != rhs.table)
396 throw std::invalid_argument(
"segment_iterator::operator<=");
398 return index <= rhs.index;
412 template <
typename Container,
bool is_const>
418 if (table != rhs.table)
419 throw std::invalid_argument(
"segment_iterator::operator>=");
421 return index >= rhs.index;
427 template <
typename Container,
bool is_const>
428 typename segment_iterator<Container, is_const>::reference
431 return table->operator[](index);
437 template <
typename Container,
bool is_const>
438 typename segment_iterator<Container, is_const>::pointer
456 segment_vector_internal::exponential_size_policy<
467 template <
size_t SegmentSize = 1024,
471 SegmentType, SegmentSize>;
505 template <
typename T,
typename Policy = exponential_size_vector_policy<>>
509 using policy_type = Policy;
510 using segment_type =
typename policy_type::template segment_type<T>;
511 using segment_vector_type =
512 typename policy_type::template segment_vector_type<T>;
514 using policy = policy_type;
515 using storage = policy_type;
518 using value_type = T;
519 using size_type = std::size_t;
520 using difference_type = std::ptrdiff_t;
521 using reference = value_type &;
522 using const_reference =
const value_type &;
523 using pointer = value_type *;
524 using const_pointer =
const value_type *;
530 using reverse_iterator = std::reverse_iterator<iterator>;
531 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
537 template <
typename InputIt,
538 typename std::enable_if<
540 InputIt>::type * =
nullptr>
554 void assign(size_type count, const_reference value);
555 template <
typename InputIt,
556 typename std::enable_if<
558 InputIt>::type * =
nullptr>
559 void assign(InputIt first, InputIt last);
560 void assign(std::initializer_list<T> ilist);
563 void assign(
const std::vector<T> &other);
569 reference
at(size_type n);
570 const_reference
at(size_type n)
const;
571 const_reference
const_at(size_type n)
const;
573 const_reference
operator[](size_type n)
const;
575 const_reference
front()
const;
576 const_reference
cfront()
const;
578 const_reference
back()
const;
579 const_reference
cback()
const;
588 reverse_iterator
rbegin();
589 const_reverse_iterator
rbegin()
const noexcept;
590 const_reverse_iterator
crbegin()
const noexcept;
591 reverse_iterator
rend();
592 const_reverse_iterator
rend()
const noexcept;
593 const_reverse_iterator
crend()
const noexcept;
601 constexpr
bool empty()
const noexcept;
602 size_type
size()
const noexcept;
603 constexpr size_type
max_size()
const noexcept;
604 void reserve(size_type capacity_new);
605 size_type
capacity()
const noexcept;
614 template <
typename InputIt,
615 typename std::enable_if<
617 InputIt>::type * =
nullptr>
620 template <
class... Args>
622 template <
class... Args>
629 void resize(size_type count);
630 void resize(size_type count,
const value_type &value);
635 void internal_reserve(size_type new_capacity);
636 template <
typename... Args>
637 void construct(size_type idx, size_type count, Args &&... args);
638 template <
typename InputIt,
639 typename std::enable_if<
641 InputIt>::type * =
nullptr>
642 void construct_range(size_type idx, InputIt first, InputIt last);
643 void insert_gap(size_type idx, size_type count);
644 void shrink(size_type size_new);
646 void snapshot_data(size_type idx_first, size_type idx_last);
649 reference get(size_type n);
650 const_reference get(size_type n)
const;
651 const_reference cget(size_type n)
const;
652 bool segment_capacity_validation()
const;
657 segment_vector_type _data;
663 template <
typename T,
typename Policy>
671 template <
typename T,
typename Policy>
674 template <
typename T,
typename Policy>
677 template <
typename T,
typename Policy>
680 template <
typename T,
typename Policy>
683 template <
typename T,
typename Policy>
686 template <
typename T,
typename Policy>
695 template <
typename T,
typename Policy>
697 const std::vector<T> &rhs);
698 template <
typename T,
typename Policy>
700 const std::vector<T> &rhs);
701 template <
typename T,
typename Policy>
703 template <
typename T,
typename Policy>
705 const std::vector<T> &rhs);
706 template <
typename T,
typename Policy>
708 template <
typename T,
typename Policy>
710 const std::vector<T> &rhs);
716 template <
typename T,
typename Policy>
717 bool operator==(
const std::vector<T> &lhs,
719 template <
typename T,
typename Policy>
720 bool operator!=(
const std::vector<T> &lhs,
722 template <
typename T,
typename Policy>
724 template <
typename T,
typename Policy>
725 bool operator<=(
const std::vector<T> &lhs,
727 template <
typename T,
typename Policy>
729 template <
typename T,
typename Policy>
730 bool operator>=(
const std::vector<T> &lhs,
741 template <
typename T,
typename Policy>
768 template <
typename T,
typename Policy>
770 const value_type &value)
772 internal_reserve(count);
773 construct(0, count, value);
797 template <
typename T,
typename Policy>
800 internal_reserve(count);
830 template <
typename T,
typename Policy>
831 template <
typename InputIt,
832 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
836 internal_reserve(
static_cast<size_type
>(std::distance(first, last)));
837 construct_range(0, first, last);
861 template <
typename T,
typename Policy>
865 construct_range(0, other.
cbegin(), other.
cend());
888 template <
typename T,
typename Policy>
891 _data = std::move(other._data);
892 _segments_used = other._segments_used;
893 other._segments_used = 0;
917 template <
typename T,
typename Policy>
944 template <
typename T,
typename Policy>
967 template <
typename T,
typename Policy>
990 template <
typename T,
typename Policy>
994 assign(std::move(other));
1015 template <
typename T,
typename Policy>
1019 assign(ilist.begin(), ilist.end());
1040 template <
typename T,
typename Policy>
1070 template <
typename T,
typename Policy>
1074 if (count > max_size())
1075 throw std::length_error(
"Assignable range exceeds max size.");
1079 if (count > capacity())
1080 internal_reserve(count);
1081 else if (count < size())
1089 size_type end = policy::get_segment(count - 1);
1090 for (size_type i = 0; i < end; ++i)
1091 _data[i].assign(policy::segment_size(i), value);
1092 _data[end].assign(count - policy::segment_top(end),
1095 _segments_used = end + 1;
1098 assert(segment_capacity_validation());
1123 template <
typename T,
typename Policy>
1124 template <
typename InputIt,
1125 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
1130 size_type count =
static_cast<size_type
>(std::distance(first, last));
1131 if (count > max_size())
1132 throw std::length_error(
"Assignable range exceeds max size.");
1136 if (count > capacity())
1137 internal_reserve(count);
1138 else if (count < size())
1146 difference_type num;
1147 size_type end = policy::get_segment(count - 1);
1148 for (size_type i = 0; i < end; ++i) {
1149 size_type size = policy::segment_size(i);
1150 num =
static_cast<difference_type
>(size);
1151 _data[i].assign(first, std::next(first, num));
1152 std::advance(first, num);
1154 num =
static_cast<difference_type
>(
1155 std::distance(first, last));
1156 _data[end].assign(first, std::next(first, num));
1158 _segments_used = end + 1;
1161 assert(segment_capacity_validation());
1184 template <
typename T,
typename Policy>
1188 assign(ilist.begin(), ilist.end());
1207 template <
typename T,
typename Policy>
1230 template <
typename T,
typename Policy>
1239 _data = std::move(other._data);
1240 _segments_used = other._segments_used;
1241 other._segments_used = 0;
1261 template <
typename T,
typename Policy>
1265 assign(other.cbegin(), other.cend());
1275 template <
typename T,
typename Policy>
1298 template <
typename T,
typename Policy>
1299 typename segment_vector<T, Policy>::reference
1303 throw std::out_of_range(
"segment_vector::at");
1320 template <
typename T,
typename Policy>
1321 typename segment_vector<T, Policy>::const_reference
1325 throw std::out_of_range(
"segment_vector::at");
1341 template <
typename T,
typename Policy>
1342 typename segment_vector<T, Policy>::const_reference
1346 throw std::out_of_range(
"segment_vector::const_at");
1361 template <
typename T,
typename Policy>
1362 typename segment_vector<T, Policy>::reference
1365 reference element = get(n);
1368 POBJ_XADD_ASSUME_INITIALIZED);
1380 template <
typename T,
typename Policy>
1381 typename segment_vector<T, Policy>::const_reference
1395 template <
typename T,
typename Policy>
1396 typename segment_vector<T, Policy>::reference
1400 POBJ_XADD_ASSUME_INITIALIZED);
1410 template <
typename T,
typename Policy>
1411 typename segment_vector<T, Policy>::const_reference
1424 template <
typename T,
typename Policy>
1425 typename segment_vector<T, Policy>::const_reference
1439 template <
typename T,
typename Policy>
1440 typename segment_vector<T, Policy>::reference
1443 reference element = get(size() - 1);
1446 POBJ_XADD_ASSUME_INITIALIZED);
1456 template <
typename T,
typename Policy>
1457 typename segment_vector<T, Policy>::const_reference
1460 return get(size() - 1);
1470 template <
typename T,
typename Policy>
1471 typename segment_vector<T, Policy>::const_reference
1474 return get(size() - 1);
1482 template <
typename T,
typename Policy>
1495 template <
typename T,
typename Policy>
1510 template <
typename T,
typename Policy>
1523 template <
typename T,
typename Policy>
1536 template <
typename T,
typename Policy>
1551 template <
typename T,
typename Policy>
1564 template <
typename T,
typename Policy>
1565 typename segment_vector<T, Policy>::reverse_iterator
1568 return reverse_iterator(end());
1577 template <
typename T,
typename Policy>
1578 typename segment_vector<T, Policy>::const_reverse_iterator
1581 return const_reverse_iterator(end());
1592 template <
typename T,
typename Policy>
1593 typename segment_vector<T, Policy>::const_reverse_iterator
1605 template <
typename T,
typename Policy>
1606 typename segment_vector<T, Policy>::reverse_iterator
1609 return reverse_iterator(begin());
1618 template <
typename T,
typename Policy>
1619 typename segment_vector<T, Policy>::const_reverse_iterator
1622 return const_reverse_iterator(begin());
1633 template <
typename T,
typename Policy>
1634 typename segment_vector<T, Policy>::const_reverse_iterator
1653 template <
typename T,
typename Policy>
1657 if (start + n > size())
1658 throw std::out_of_range(
"segment_vector::range");
1660 snapshot_data(start, start + n);
1676 template <
typename T,
typename Policy>
1680 if (start + n > size())
1681 throw std::out_of_range(
"segment_vector::range");
1697 template <
typename T,
typename Policy>
1701 if (start + n > size())
1702 throw std::out_of_range(
"segment_vector::range");
1712 template <
typename T,
typename Policy>
1722 template <
typename T,
typename Policy>
1723 typename segment_vector<T, Policy>::size_type
1726 size_type result = 0;
1729 for (size_type i = 0; i < _segments_used; ++i)
1730 result += _data.const_at(i).size();
1731 }
catch (std::out_of_range &) {
1743 template <
typename T,
typename Policy>
1744 constexpr
typename segment_vector<T, Policy>::size_type
1747 return policy::max_size(_data);
1766 template <
typename T,
typename Policy>
1770 if (capacity_new <= capacity())
1781 template <
typename T,
typename Policy>
1782 typename segment_vector<T, Policy>::size_type
1785 if (_segments_used == 0)
1787 return policy::capacity(_segments_used - 1);
1801 template <
typename T,
typename Policy>
1807 size_type new_last = policy::get_segment(size() - 1);
1808 if (_segments_used - 1 == new_last)
1813 for (size_type i = new_last + 1; i < _segments_used; ++i)
1814 _data[i].free_data();
1815 _segments_used = new_last + 1;
1816 storage::resize(_data, _segments_used);
1831 template <
typename T,
typename Policy>
1837 assert(segment_capacity_validation());
1852 template <
typename T,
typename Policy>
1858 for (size_type i = 0; i < _segments_used; ++i)
1859 _data[i].free_data();
1887 template <
typename T,
typename Policy>
1891 return insert(pos, 1, value);
1917 template <
typename T,
typename Policy>
1921 size_type idx =
static_cast<size_type
>(pos - cbegin());
1926 get(idx) = std::move(value);
1958 template <
typename T,
typename Policy>
1963 size_type idx =
static_cast<size_type
>(pos - cbegin());
1967 insert_gap(idx, count);
1968 for (size_type i = idx; i < idx + count; ++i)
1969 get(i) = std::move(value);
2008 template <
typename T,
typename Policy>
2009 template <
typename InputIt,
2010 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
2016 size_type idx =
static_cast<size_type
>(pos - cbegin());
2017 size_type gap_size =
static_cast<size_type
>(std::distance(first, last));
2021 insert_gap(idx, gap_size);
2022 for (size_type i = idx; i < idx + gap_size; ++i, ++first)
2055 template <
typename T,
typename Policy>
2058 std::initializer_list<T> ilist)
2060 return insert(pos, ilist.begin(), ilist.end());
2091 template <
typename T,
typename Policy>
2092 template <
class... Args>
2096 size_type idx =
static_cast<size_type
>(pos - cbegin());
2101 noexcept(T(std::forward<Args>(args)...))>
2102 tmp(std::forward<Args>(args)...);
2104 get(idx) = std::move(tmp.get());
2134 template <
typename T,
typename Policy>
2135 template <
class... Args>
2136 typename segment_vector<T, Policy>::reference
2139 assert(size() < max_size());
2143 if (size() == capacity())
2144 internal_reserve(capacity() + 1);
2146 size_type segment = policy::get_segment(size());
2147 _data[segment].emplace_back(std::forward<Args>(args)...);
2174 template <
typename T,
typename Policy>
2178 return erase(pos, pos + 1);
2205 template <
typename T,
typename Policy>
2209 size_type count =
static_cast<size_type
>(std::distance(first, last));
2210 size_type idx =
static_cast<size_type
>(first - cbegin());
2217 size_type _size = size();
2219 if (!std::is_trivially_destructible<T>::value ||
2220 idx + count < _size)
2221 snapshot_data(idx, _size);
2228 std::move(begin, end, dest);
2232 size_type middle = policy::get_segment(_size - count);
2233 size_type last = policy::get_segment(_size - 1);
2234 size_type middle_size = policy::index_in_segment(_size - count);
2235 for (size_type s = last; s > middle; --s)
2237 _data[middle].resize(middle_size);
2239 _segments_used = middle + 1;
2242 assert(segment_capacity_validation());
2265 template <
typename T,
typename Policy>
2269 emplace_back(value);
2290 template <
typename T,
typename Policy>
2294 emplace_back(std::move(value));
2310 template <
typename T,
typename Policy>
2319 assert(segment_capacity_validation());
2345 template <
typename T,
typename Policy>
2351 size_type _size = size();
2355 if (capacity() < count)
2356 internal_reserve(count);
2357 construct(_size, count - _size);
2360 assert(segment_capacity_validation());
2387 template <
typename T,
typename Policy>
2393 size_type _size = size();
2397 if (capacity() < count)
2398 internal_reserve(count);
2399 construct(_size, count - _size, value);
2402 assert(segment_capacity_validation());
2408 template <
typename T,
typename Policy>
2414 _data.swap(other._data);
2415 std::swap(_segments_used, other._segments_used);
2434 template <
typename T,
typename Policy>
2438 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2440 if (new_capacity > max_size())
2441 throw std::length_error(
"New capacity exceeds max size.");
2443 if (new_capacity == 0)
2446 size_type old_idx = policy::get_segment(capacity());
2447 size_type new_idx = policy::get_segment(new_capacity - 1);
2448 storage::resize(_data, new_idx + 1);
2449 for (size_type i = old_idx; i <= new_idx; ++i) {
2450 size_type segment_capacity = policy::segment_size(i);
2451 _data[i].reserve(segment_capacity);
2453 _segments_used = new_idx + 1;
2455 assert(segment_capacity_validation());
2484 template <
typename T,
typename Policy>
2485 template <
typename... Args>
2487 segment_vector<T, Policy>::construct(size_type idx, size_type count,
2490 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2491 assert(capacity() >= size() + count);
2493 for (size_type i = idx; i < idx + count; ++i) {
2494 size_type segment = policy::get_segment(i);
2495 _data[segment].emplace_back(std::forward<Args>(args)...);
2498 assert(segment_capacity_validation());
2531 template <
typename T,
typename Policy>
2532 template <
typename InputIt,
2533 typename std::enable_if<detail::is_input_iterator<InputIt>::value,
2536 segment_vector<T, Policy>::construct_range(size_type idx, InputIt first,
2539 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2540 size_type count =
static_cast<size_type
>(std::distance(first, last));
2541 assert(capacity() >= size() + count);
2543 for (size_type i = idx; i < idx + count; ++i, ++first) {
2544 size_type segment = policy::get_segment(i);
2545 _data[segment].emplace_back(*first);
2548 assert(segment_capacity_validation());
2572 template <
typename T,
typename Policy>
2574 segment_vector<T, Policy>::insert_gap(size_type idx, size_type count)
2576 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2580 size_type _size = size();
2582 if (capacity() < _size + count)
2583 internal_reserve(_size + count);
2585 iterator dest = iterator(
this, _size + count);
2586 iterator begin = iterator(
this, idx);
2587 iterator end = iterator(
this, _size);
2589 snapshot_data(idx, _size);
2591 resize(_size + count);
2592 std::move_backward(begin, end, dest);
2594 assert(segment_capacity_validation());
2616 template <
typename T,
typename Policy>
2618 segment_vector<T, Policy>::shrink(size_type size_new)
2620 assert(pmemobj_tx_stage() == TX_STAGE_WORK);
2621 assert(size_new <= size());
2626 if (!std::is_trivially_destructible<T>::value)
2627 snapshot_data(size_new, size());
2629 size_type begin = policy::get_segment(size() - 1);
2630 size_type end = policy::get_segment(size_new);
2631 for (; begin > end; --begin) {
2632 _data[begin].clear();
2634 size_type residue = policy::index_in_segment(size_new);
2635 _data[end].erase(_data[end].cbegin() + residue, _data[end].cend());
2637 assert(segment_capacity_validation());
2647 template <
typename T,
typename Policy>
2649 segment_vector<T, Policy>::get_pool()
const
2663 template <
typename T,
typename Policy>
2665 segment_vector<T, Policy>::snapshot_data(size_type first, size_type last)
2670 size_type segment = policy::get_segment(first);
2671 size_type end = policy::get_segment(last - 1);
2672 size_type count = policy::segment_top(segment + 1) - first;
2674 while (segment != end) {
2676 POBJ_XADD_ASSUME_INITIALIZED);
2677 first = policy::segment_top(++segment);
2678 count = policy::segment_size(segment);
2681 POBJ_XADD_ASSUME_INITIALIZED);
2689 template <
typename T,
typename Policy>
2690 typename segment_vector<T, Policy>::reference
2691 segment_vector<T, Policy>::get(size_type n)
2693 size_type s_idx = policy::get_segment(n);
2694 size_type local_idx = policy::index_in_segment(n);
2696 return _data[s_idx][local_idx];
2704 template <
typename T,
typename Policy>
2705 typename segment_vector<T, Policy>::const_reference
2706 segment_vector<T, Policy>::get(size_type n)
const
2708 size_type s_idx = policy::get_segment(n);
2709 size_type local_idx = policy::index_in_segment(n);
2711 return _data[s_idx][local_idx];
2719 template <
typename T,
typename Policy>
2720 typename segment_vector<T, Policy>::const_reference
2721 segment_vector<T, Policy>::cget(size_type n)
const
2723 size_type s_idx = policy::get_segment(n);
2724 size_type local_idx = policy::index_in_segment(n);
2726 return _data[s_idx][local_idx];
2736 template <
typename T,
typename Policy>
2738 segment_vector<T, Policy>::segment_capacity_validation()
const
2740 for (size_type i = 0; i < _segments_used; ++i)
2741 if (_data.const_at(i).capacity() != policy::segment_size(i))
2753 template <
typename T,
typename Policy>
2775 template <
typename T,
typename Policy>
2800 template <
typename T,
typename Policy>
2805 return !(lhs == rhs);
2821 template <
typename T,
typename Policy>
2826 return std::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(),
2843 template <
typename T,
typename Policy>
2848 return !(rhs < lhs);
2864 template <
typename T,
typename Policy>
2885 template <
typename T,
typename Policy>
2890 return !(lhs < rhs);
2907 template <
typename T,
typename Policy>
2911 return lhs.
size() == rhs.size() &&
2912 std::equal(lhs.
begin(), lhs.
end(), rhs.begin());
2929 template <
typename T,
typename Policy>
2933 return !(lhs == rhs);
2948 template <
typename T,
typename Policy>
2952 return std::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.begin(),
2968 template <
typename T,
typename Policy>
2972 return !(std::lexicographical_compare(rhs.begin(), rhs.end(),
2989 template <
typename T,
typename Policy>
2993 return !(lhs <= rhs);
3008 template <
typename T,
typename Policy>
3012 return !(lhs < rhs);
3029 template <
typename T,
typename Policy>
3050 template <
typename T,
typename Policy>
3054 return !(lhs == rhs);
3069 template <
typename T,
typename Policy>
3088 template <
typename T,
typename Policy>
3092 return !(rhs < lhs);
3108 template <
typename T,
typename Policy>
3127 template <
typename T,
typename Policy>
3131 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:810
The non-template pool base class.
Definition: pool.hpp:51
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
Persistent version of segment vector with std::vector compatible interface.
Definition: segment_vector.hpp:506
reference front()
Access the first element and add this element to a transaction.
Definition: segment_vector.hpp:1397
void reserve(size_type capacity_new)
Increases the capacity of the segment_vector to capacity_new transactionally.
Definition: segment_vector.hpp:1768
constexpr bool empty() const noexcept
Checks whether the container is empty.
Definition: segment_vector.hpp:1714
const_reverse_iterator crbegin() const noexcept
Returns a const reverse iterator to the beginning.
Definition: segment_vector.hpp:1594
size_type capacity() const noexcept
Definition: segment_vector.hpp:1783
bool operator>(const segment_vector< T, Policy > &lhs, const std::vector< T > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2991
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition: segment_vector.hpp:1566
constexpr size_type max_size() const noexcept
Definition: segment_vector.hpp:1745
reference emplace_back(Args &&... args)
Appends a new element to the end of the container transactionally.
Definition: segment_vector.hpp:2137
reference at(size_type n)
Access element at specific index with bounds checking and add it to a transaction.
Definition: segment_vector.hpp:1300
reference operator[](size_type n)
Access element at specific index and add it to a transaction.
Definition: segment_vector.hpp:1363
const_reference cfront() const
Access the first element.
Definition: segment_vector.hpp:1426
void swap(segment_vector &other)
Exchanges the contents of the container with other transactionally.
Definition: segment_vector.hpp:2410
void clear()
Clears the content of a segment_vector transactionally.
Definition: segment_vector.hpp:1833
bool operator>=(const segment_vector< T, Policy > &lhs, const std::vector< T > &rhs)
Comparison operator.
Definition: segment_vector.hpp:3010
~segment_vector()
Destructor.
Definition: segment_vector.hpp:1276
const_reference const_at(size_type n) const
Access element at specific index with bounds checking.
Definition: segment_vector.hpp:1343
const_reference cback() const
Access the last element.
Definition: segment_vector.hpp:1472
iterator begin()
Returns an iterator to the beginning.
Definition: segment_vector.hpp:1484
void resize(size_type count)
Resizes the container to count elements transactionally.
Definition: segment_vector.hpp:2347
bool operator==(const segment_vector< T, Policy > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2777
reference back()
Access the last element and add this element to a transaction.
Definition: segment_vector.hpp:1441
bool operator!=(const segment_vector< T, Policy > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2802
bool operator>=(const segment_vector< T, Policy > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2887
const_reverse_iterator crend() const noexcept
Returns a const reverse iterator to the beginning.
Definition: segment_vector.hpp:1635
bool operator>=(const std::vector< T > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:3129
void push_back(const T &value)
Appends the given element value to the end of the container transactionally.
Definition: segment_vector.hpp:2267
slice< iterator > range(size_type start, size_type n)
Returns slice and snapshots requested range.
Definition: segment_vector.hpp:1655
size_type size() const noexcept
Definition: segment_vector.hpp:1724
bool operator==(const std::vector< T > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:3031
bool operator!=(const segment_vector< T, Policy > &lhs, const std::vector< T > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2931
void free_data()
Clears the content of a segment_vector and frees all allocated persistent memory for data transaction...
Definition: segment_vector.hpp:1854
iterator erase(const_iterator pos)
Removes the element at pos.
Definition: segment_vector.hpp:2176
bool operator==(const segment_vector< T, Policy > &lhs, const std::vector< T > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2909
iterator emplace(const_iterator pos, Args &&... args)
Inserts a new element into the container directly before pos.
Definition: segment_vector.hpp:2094
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition: segment_vector.hpp:1607
segment_vector()
Default constructor.
Definition: segment_vector.hpp:742
segment_vector & operator=(const segment_vector &other)
Copy assignment operator.
Definition: segment_vector.hpp:969
iterator end()
Returns an iterator to past the end.
Definition: segment_vector.hpp:1525
void pop_back()
Removes the last element of the container transactionally.
Definition: segment_vector.hpp:2312
void shrink_to_fit()
Requests transactional removal of unused capacity.
Definition: segment_vector.hpp:1803
iterator insert(const_iterator pos, const T &value)
Inserts value before pos in the container transactionally.
Definition: segment_vector.hpp:1889
bool operator>(const std::vector< T > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:3110
const_iterator cend() const noexcept
Returns a const iterator to the end.
Definition: segment_vector.hpp:1553
slice< const_iterator > crange(size_type start, size_type n) const
Returns const slice.
Definition: segment_vector.hpp:1699
bool operator>(const segment_vector< T, Policy > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:2866
bool operator!=(const std::vector< T > &lhs, const segment_vector< T, Policy > &rhs)
Comparison operator.
Definition: segment_vector.hpp:3052
void assign(size_type count, const_reference value)
Replaces the contents with count copies of value value transactionally.
Definition: segment_vector.hpp:1072
void swap(segment_vector< T, Policy > &lhs, segment_vector< T, Policy > &rhs)
Swaps the contents of lhs and rhs.
Definition: segment_vector.hpp:2755
const_iterator cbegin() const noexcept
Returns const iterator to the beginning.
Definition: segment_vector.hpp:1512
Provides interface to access sequence of objects.
Definition: slice.hpp:61
Persistent container with std::vector compatible interface.
Definition: vector.hpp:41
Commonly used functionality.
Functions for lifetime management.
persistent_ptr transactional allocation functions for objects.
void conditional_add_to_tx(const T *that, std::size_t count=1, uint64_t flags=0)
Conditionally add 'count' objects to a transaction.
Definition: common.hpp:176
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
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
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.
Template class for caching objects based on constructor's variadic template arguments and LIBPMEMOBJ_...
Definition: temp_value.hpp:35
Persistent container with std::array compatible interface.
Definition: array.hpp:57
template class for caching objects.
Commonly used SFINAE helpers.
C++ pmemobj transactions.
Vector container with std::vector compatible interface.