PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
concurrent_map.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2019-2021, Intel Corporation */
3 
9 #ifndef PMEMOBJ_CONCURRENT_MAP_HPP
10 #define PMEMOBJ_CONCURRENT_MAP_HPP
11 
15 
16 namespace pmem
17 {
18 namespace obj
19 {
20 namespace experimental
21 {
22 
54 template <typename Key, typename Value, typename Comp = std::less<Key>,
55  typename Allocator =
56  pmem::obj::allocator<detail::pair<const Key, Value>>>
58  : public detail::concurrent_skip_list<detail::map_traits<
59  Key, Value, Comp, detail::default_random_generator, Allocator,
60  false, 64>> {
61  using traits_type = detail::map_traits<Key, Value, Comp,
62  detail::default_random_generator,
63  Allocator, false, 64>;
65 
66 public:
67  using key_type = typename base_type::key_type;
68  using mapped_type = typename base_type::mapped_type;
69  using value_type = typename base_type::value_type;
70  using size_type = typename base_type::size_type;
71  using difference_type = typename base_type::difference_type;
72  using key_compare = Comp;
73  using allocator_type = Allocator;
74  using reference = typename base_type::reference;
75  using const_reference = typename base_type::const_reference;
76  using pointer = typename base_type::pointer;
77  using const_pointer = typename base_type::const_pointer;
78  using iterator = typename base_type::iterator;
79  using const_iterator = typename base_type::const_iterator;
80 
84  concurrent_map() = default;
85 
89  concurrent_map(const concurrent_map &table) : base_type(table)
90  {
91  }
92 
96  concurrent_map(concurrent_map &&table) : base_type(std::move(table))
97  {
98  }
99 
103  explicit concurrent_map(const key_compare &comp,
104  const allocator_type &alloc = allocator_type())
105  : base_type(comp, alloc)
106  {
107  }
108 
112  template <class InputIt>
113  concurrent_map(InputIt first, InputIt last,
114  const key_compare &comp = Comp(),
115  const allocator_type &alloc = allocator_type())
116  : base_type(first, last, comp, alloc)
117  {
118  }
119 
123  concurrent_map(std::initializer_list<value_type> ilist)
124  : base_type(ilist.begin(), ilist.end())
125  {
126  }
127 
132  operator=(const concurrent_map &other)
133  {
134  return static_cast<concurrent_map &>(
135  base_type::operator=(other));
136  }
137 
143  {
144  return static_cast<concurrent_map &>(
145  base_type::operator=(std::move(other)));
146  }
147 
152  operator=(std::initializer_list<value_type> ilist)
153  {
154  return static_cast<concurrent_map &>(
155  base_type::operator=(ilist));
156  }
157 };
158 
162 template <typename Key, typename Value, typename Comp, typename Allocator>
163 void
166 {
167  lhs.swap(rhs);
168 }
169 
170 } /* namespace experimental */
171 } /* namespace obj */
172 } /* namespace pmem */
173 #endif /* PMEMOBJ_CONCURRENT_MAP_HPP */
Persistent memory aware allocator.
Persistent memory aware implementation of the concurrent skip list.
Definition: concurrent_skip_list_impl.hpp:484
concurrent_skip_list & operator=(const concurrent_skip_list &other)
Copy assignment operator.
Definition: concurrent_skip_list_impl.hpp:801
Persistent memory aware implementation of Intel TBB concurrent_map with API partially compatible to s...
Definition: concurrent_map.hpp:60
void swap(concurrent_map< Key, Value, Comp, Allocator > &lhs, concurrent_map< Key, Value, Comp, Allocator > &rhs)
Non-member swap.
Definition: concurrent_map.hpp:164
concurrent_map(std::initializer_list< value_type > ilist)
Constructs the map with initializer list.
Definition: concurrent_map.hpp:123
concurrent_map & operator=(const concurrent_map &other)
Assignment operator.
Definition: concurrent_map.hpp:132
concurrent_map(concurrent_map &&table)
Move constructor.
Definition: concurrent_map.hpp:96
concurrent_map(const key_compare &comp, const allocator_type &alloc=allocator_type())
Construct the empty map.
Definition: concurrent_map.hpp:103
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:113
concurrent_map & operator=(concurrent_map &&other)
Move-assignment operator.
Definition: concurrent_map.hpp:142
concurrent_map(const concurrent_map &table)
Copy constructor.
Definition: concurrent_map.hpp:89
Persistent memory aware implementation of the concurrent skip list.
Persistent memory namespace.
Definition: allocation_flag.hpp:15
Pair implementation.