PMDK C++ bindings  1.13.0-git23.gf49772ac
This is the C++ bindings documentation for PMDK's libpmemobj.
concurrent_map.hpp
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2019-2020, Intel Corporation */
3 
4 #ifndef PMEMOBJ_CONCURRENT_MAP_HPP
5 #define PMEMOBJ_CONCURRENT_MAP_HPP
6 
8 #include <libpmemobj++/container/detail/concurrent_skip_list_impl.hpp>
9 #include <libpmemobj++/detail/pair.hpp>
10 
11 namespace pmem
12 {
13 namespace obj
14 {
15 namespace experimental
16 {
43 template <typename Key, typename Value, typename Comp = std::less<Key>,
44  typename Allocator =
45  pmem::obj::allocator<detail::pair<const Key, Value>>>
47  : public detail::concurrent_skip_list<detail::map_traits<
48  Key, Value, Comp, detail::default_random_generator, Allocator,
49  false, 64>> {
50  using traits_type = detail::map_traits<Key, Value, Comp,
51  detail::default_random_generator,
52  Allocator, false, 64>;
54 
55 public:
56  using key_type = typename base_type::key_type;
57  using mapped_type = typename base_type::mapped_type;
58  using value_type = typename base_type::value_type;
59  using size_type = typename base_type::size_type;
60  using difference_type = typename base_type::difference_type;
61  using key_compare = Comp;
62  using allocator_type = Allocator;
63  using reference = typename base_type::reference;
64  using const_reference = typename base_type::const_reference;
65  using pointer = typename base_type::pointer;
66  using const_pointer = typename base_type::const_pointer;
67  using iterator = typename base_type::iterator;
68  using const_iterator = typename base_type::const_iterator;
69 
73  concurrent_map() = default;
74 
78  concurrent_map(const concurrent_map &table) : base_type(table)
79  {
80  }
81 
85  concurrent_map(concurrent_map &&table) : base_type(std::move(table))
86  {
87  }
88 
92  explicit concurrent_map(const key_compare &comp,
93  const allocator_type &alloc = allocator_type())
94  : base_type(comp, alloc)
95  {
96  }
97 
101  template <class InputIt>
102  concurrent_map(InputIt first, InputIt last,
103  const key_compare &comp = Comp(),
104  const allocator_type &alloc = allocator_type())
105  : base_type(first, last, comp, alloc)
106  {
107  }
108 
112  concurrent_map(std::initializer_list<value_type> ilist)
113  : base_type(ilist.begin(), ilist.end())
114  {
115  }
116 
121  operator=(const concurrent_map &other)
122  {
123  return static_cast<concurrent_map &>(
124  base_type::operator=(other));
125  }
126 
132  {
133  return static_cast<concurrent_map &>(
134  base_type::operator=(std::move(other)));
135  }
136 
141  operator=(std::initializer_list<value_type> ilist)
142  {
143  return static_cast<concurrent_map &>(
144  base_type::operator=(ilist));
145  }
146 };
147 
149 template <typename Key, typename Value, typename Comp, typename Allocator>
150 void
153 {
154  lhs.swap(rhs);
155 }
156 
157 } /* namespace experimental */
158 } /* namespace obj */
159 } /* namespace pmem */
160 #endif /* PMEMOBJ_CONCURRENT_MAP_HPP */
Persistent memory aware allocator.
Persistent memory aware implementation of the concurrent skip list.
Definition: concurrent_skip_list_impl.hpp:479
concurrent_skip_list & operator=(const concurrent_skip_list &other)
Copy assignment operator.
Definition: concurrent_skip_list_impl.hpp:796
Persistent memory aware implementation of Intel TBB concurrent_map.
Definition: concurrent_map.hpp:49
concurrent_map(std::initializer_list< value_type > ilist)
Constructs the map with initializer list.
Definition: concurrent_map.hpp:112
concurrent_map & operator=(const concurrent_map &other)
Assignment operator.
Definition: concurrent_map.hpp:121
concurrent_map(concurrent_map &&table)
Move constructor.
Definition: concurrent_map.hpp:85
concurrent_map(const key_compare &comp, const allocator_type &alloc=allocator_type())
Construct the empty map.
Definition: concurrent_map.hpp:92
concurrent_map()=default
Default constructor.
concurrent_map(InputIt first, InputIt last, const key_compare &comp=Comp(), const allocator_type &alloc=allocator_type())
Constructs the map with the contents of the range [first, last).
Definition: concurrent_map.hpp:102
concurrent_map & operator=(concurrent_map &&other)
Move-assignment operator.
Definition: concurrent_map.hpp:131
concurrent_map(const concurrent_map &table)
Copy constructor.
Definition: concurrent_map.hpp:78
void swap(concurrent_map< Key, Value, Comp, Allocator > &lhs, concurrent_map< Key, Value, Comp, Allocator > &rhs)
Non-member swap.
Definition: concurrent_map.hpp:151
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 >::iterator begin(pmem::obj::array< T, N > &a)
Non-member begin.
Definition: array.hpp:829
Persistent memory namespace.
Definition: allocation_flag.hpp:15