tmp/tmprwn1i57h/{from.md → to.md}
RENAMED
|
@@ -1,30 +1,29 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
A `set` is an associative container that supports unique keys (contains
|
| 4 |
at most one of each key value) and provides for fast retrieval of the
|
| 5 |
keys themselves. The `set` class supports bidirectional iterators.
|
| 6 |
|
| 7 |
-
A `set`
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
information.
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
namespace std {
|
| 21 |
template<class Key, class Compare = less<Key>,
|
| 22 |
class Allocator = allocator<Key>>
|
| 23 |
class set {
|
| 24 |
public:
|
| 25 |
-
// types
|
| 26 |
using key_type = Key;
|
| 27 |
using key_compare = Compare;
|
| 28 |
using value_type = Key;
|
| 29 |
using value_compare = Compare;
|
| 30 |
using allocator_type = Allocator;
|
|
@@ -37,11 +36,11 @@ namespace std {
|
|
| 37 |
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
| 38 |
using const_iterator = implementation-defined // type of set::const_iterator; // see [container.requirements]
|
| 39 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 40 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 41 |
using node_type = unspecified;
|
| 42 |
-
using insert_return_type =
|
| 43 |
|
| 44 |
// [set.cons], construct/copy/destroy
|
| 45 |
set() : set(Compare()) { }
|
| 46 |
explicit set(const Compare& comp, const Allocator& = Allocator());
|
| 47 |
template<class InputIterator>
|
|
@@ -65,11 +64,11 @@ namespace std {
|
|
| 65 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 66 |
is_nothrow_move_assignable_v<Compare>);
|
| 67 |
set& operator=(initializer_list<value_type>);
|
| 68 |
allocator_type get_allocator() const noexcept;
|
| 69 |
|
| 70 |
-
// iterators
|
| 71 |
iterator begin() noexcept;
|
| 72 |
const_iterator begin() const noexcept;
|
| 73 |
iterator end() noexcept;
|
| 74 |
const_iterator end() const noexcept;
|
| 75 |
|
|
@@ -81,16 +80,16 @@ namespace std {
|
|
| 81 |
const_iterator cbegin() const noexcept;
|
| 82 |
const_iterator cend() const noexcept;
|
| 83 |
const_reverse_iterator crbegin() const noexcept;
|
| 84 |
const_reverse_iterator crend() const noexcept;
|
| 85 |
|
| 86 |
-
// capacity
|
| 87 |
-
bool
|
| 88 |
size_type size() const noexcept;
|
| 89 |
size_type max_size() const noexcept;
|
| 90 |
|
| 91 |
-
// modifiers
|
| 92 |
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 93 |
template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 94 |
pair<iterator,bool> insert(const value_type& x);
|
| 95 |
pair<iterator,bool> insert(value_type&& x);
|
| 96 |
iterator insert(const_iterator position, const value_type& x);
|
|
@@ -120,23 +119,26 @@ namespace std {
|
|
| 120 |
template<class C2>
|
| 121 |
void merge(multiset<Key, C2, Allocator>& source);
|
| 122 |
template<class C2>
|
| 123 |
void merge(multiset<Key, C2, Allocator>&& source);
|
| 124 |
|
| 125 |
-
// observers
|
| 126 |
key_compare key_comp() const;
|
| 127 |
value_compare value_comp() const;
|
| 128 |
|
| 129 |
-
// set operations
|
| 130 |
iterator find(const key_type& x);
|
| 131 |
const_iterator find(const key_type& x) const;
|
| 132 |
template<class K> iterator find(const K& x);
|
| 133 |
template<class K> const_iterator find(const K& x) const;
|
| 134 |
|
| 135 |
size_type count(const key_type& x) const;
|
| 136 |
template<class K> size_type count(const K& x) const;
|
| 137 |
|
|
|
|
|
|
|
|
|
|
| 138 |
iterator lower_bound(const key_type& x);
|
| 139 |
const_iterator lower_bound(const key_type& x) const;
|
| 140 |
template<class K> iterator lower_bound(const K& x);
|
| 141 |
template<class K> const_iterator lower_bound(const K& x) const;
|
| 142 |
|
|
@@ -152,48 +154,29 @@ namespace std {
|
|
| 152 |
template<class K>
|
| 153 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 154 |
};
|
| 155 |
|
| 156 |
template<class InputIterator,
|
| 157 |
-
class Compare = less<
|
| 158 |
-
class Allocator = allocator<
|
| 159 |
set(InputIterator, InputIterator,
|
| 160 |
Compare = Compare(), Allocator = Allocator())
|
| 161 |
-
-> set<
|
| 162 |
|
| 163 |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 164 |
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 165 |
-> set<Key, Compare, Allocator>;
|
| 166 |
|
| 167 |
template<class InputIterator, class Allocator>
|
| 168 |
set(InputIterator, InputIterator, Allocator)
|
| 169 |
-
-> set<
|
| 170 |
-
less<
|
| 171 |
|
| 172 |
template<class Key, class Allocator>
|
| 173 |
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
|
| 174 |
|
| 175 |
-
|
| 176 |
-
bool operator==(const set<Key, Compare, Allocator>& x,
|
| 177 |
-
const set<Key, Compare, Allocator>& y);
|
| 178 |
-
template <class Key, class Compare, class Allocator>
|
| 179 |
-
bool operator< (const set<Key, Compare, Allocator>& x,
|
| 180 |
-
const set<Key, Compare, Allocator>& y);
|
| 181 |
-
template <class Key, class Compare, class Allocator>
|
| 182 |
-
bool operator!=(const set<Key, Compare, Allocator>& x,
|
| 183 |
-
const set<Key, Compare, Allocator>& y);
|
| 184 |
-
template <class Key, class Compare, class Allocator>
|
| 185 |
-
bool operator> (const set<Key, Compare, Allocator>& x,
|
| 186 |
-
const set<Key, Compare, Allocator>& y);
|
| 187 |
-
template <class Key, class Compare, class Allocator>
|
| 188 |
-
bool operator>=(const set<Key, Compare, Allocator>& x,
|
| 189 |
-
const set<Key, Compare, Allocator>& y);
|
| 190 |
-
template <class Key, class Compare, class Allocator>
|
| 191 |
-
bool operator<=(const set<Key, Compare, Allocator>& x,
|
| 192 |
-
const set<Key, Compare, Allocator>& y);
|
| 193 |
-
|
| 194 |
-
// [set.special], specialized algorithms
|
| 195 |
template<class Key, class Compare, class Allocator>
|
| 196 |
void swap(set<Key, Compare, Allocator>& x,
|
| 197 |
set<Key, Compare, Allocator>& y)
|
| 198 |
noexcept(noexcept(x.swap(y)));
|
| 199 |
}
|
|
|
|
| 1 |
+
#### Overview <a id="set.overview">[[set.overview]]</a>
|
| 2 |
|
| 3 |
A `set` is an associative container that supports unique keys (contains
|
| 4 |
at most one of each key value) and provides for fast retrieval of the
|
| 5 |
keys themselves. The `set` class supports bidirectional iterators.
|
| 6 |
|
| 7 |
+
A `set` meets all of the requirements of a container, of a reversible
|
| 8 |
+
container [[container.requirements]], of an associative container
|
| 9 |
+
[[associative.reqmts]], and of an allocator-aware container (
|
| 10 |
+
[[container.alloc.req]]). A `set` also provides most operations
|
| 11 |
+
described in [[associative.reqmts]] for unique keys. This means that a
|
| 12 |
+
`set` supports the `a_uniq` operations in [[associative.reqmts]] but
|
| 13 |
+
not the `a_eq` operations. For a `set<Key>` both the `key_type` and
|
| 14 |
+
`value_type` are `Key`. Descriptions are provided here only for
|
| 15 |
+
operations on `set` that are not described in one of these tables and
|
| 16 |
+
for operations where there is additional semantic information.
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
namespace std {
|
| 20 |
template<class Key, class Compare = less<Key>,
|
| 21 |
class Allocator = allocator<Key>>
|
| 22 |
class set {
|
| 23 |
public:
|
| 24 |
+
// types
|
| 25 |
using key_type = Key;
|
| 26 |
using key_compare = Compare;
|
| 27 |
using value_type = Key;
|
| 28 |
using value_compare = Compare;
|
| 29 |
using allocator_type = Allocator;
|
|
|
|
| 36 |
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
| 37 |
using const_iterator = implementation-defined // type of set::const_iterator; // see [container.requirements]
|
| 38 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 39 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 40 |
using node_type = unspecified;
|
| 41 |
+
using insert_return_type = insert-return-type<iterator, node_type>;
|
| 42 |
|
| 43 |
// [set.cons], construct/copy/destroy
|
| 44 |
set() : set(Compare()) { }
|
| 45 |
explicit set(const Compare& comp, const Allocator& = Allocator());
|
| 46 |
template<class InputIterator>
|
|
|
|
| 64 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 65 |
is_nothrow_move_assignable_v<Compare>);
|
| 66 |
set& operator=(initializer_list<value_type>);
|
| 67 |
allocator_type get_allocator() const noexcept;
|
| 68 |
|
| 69 |
+
// iterators
|
| 70 |
iterator begin() noexcept;
|
| 71 |
const_iterator begin() const noexcept;
|
| 72 |
iterator end() noexcept;
|
| 73 |
const_iterator end() const noexcept;
|
| 74 |
|
|
|
|
| 80 |
const_iterator cbegin() const noexcept;
|
| 81 |
const_iterator cend() const noexcept;
|
| 82 |
const_reverse_iterator crbegin() const noexcept;
|
| 83 |
const_reverse_iterator crend() const noexcept;
|
| 84 |
|
| 85 |
+
// capacity
|
| 86 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 87 |
size_type size() const noexcept;
|
| 88 |
size_type max_size() const noexcept;
|
| 89 |
|
| 90 |
+
// modifiers
|
| 91 |
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 92 |
template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 93 |
pair<iterator,bool> insert(const value_type& x);
|
| 94 |
pair<iterator,bool> insert(value_type&& x);
|
| 95 |
iterator insert(const_iterator position, const value_type& x);
|
|
|
|
| 119 |
template<class C2>
|
| 120 |
void merge(multiset<Key, C2, Allocator>& source);
|
| 121 |
template<class C2>
|
| 122 |
void merge(multiset<Key, C2, Allocator>&& source);
|
| 123 |
|
| 124 |
+
// observers
|
| 125 |
key_compare key_comp() const;
|
| 126 |
value_compare value_comp() const;
|
| 127 |
|
| 128 |
+
// set operations
|
| 129 |
iterator find(const key_type& x);
|
| 130 |
const_iterator find(const key_type& x) const;
|
| 131 |
template<class K> iterator find(const K& x);
|
| 132 |
template<class K> const_iterator find(const K& x) const;
|
| 133 |
|
| 134 |
size_type count(const key_type& x) const;
|
| 135 |
template<class K> size_type count(const K& x) const;
|
| 136 |
|
| 137 |
+
bool contains(const key_type& x) const;
|
| 138 |
+
template<class K> bool contains(const K& x) const;
|
| 139 |
+
|
| 140 |
iterator lower_bound(const key_type& x);
|
| 141 |
const_iterator lower_bound(const key_type& x) const;
|
| 142 |
template<class K> iterator lower_bound(const K& x);
|
| 143 |
template<class K> const_iterator lower_bound(const K& x) const;
|
| 144 |
|
|
|
|
| 154 |
template<class K>
|
| 155 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 156 |
};
|
| 157 |
|
| 158 |
template<class InputIterator,
|
| 159 |
+
class Compare = less<iter-value-type<InputIterator>>,
|
| 160 |
+
class Allocator = allocator<iter-value-type<InputIterator>>>
|
| 161 |
set(InputIterator, InputIterator,
|
| 162 |
Compare = Compare(), Allocator = Allocator())
|
| 163 |
+
-> set<iter-value-type<InputIterator>, Compare, Allocator>;
|
| 164 |
|
| 165 |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 166 |
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 167 |
-> set<Key, Compare, Allocator>;
|
| 168 |
|
| 169 |
template<class InputIterator, class Allocator>
|
| 170 |
set(InputIterator, InputIterator, Allocator)
|
| 171 |
+
-> set<iter-value-type<InputIterator>,
|
| 172 |
+
less<iter-value-type<InputIterator>>, Allocator>;
|
| 173 |
|
| 174 |
template<class Key, class Allocator>
|
| 175 |
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
|
| 176 |
|
| 177 |
+
// swap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
template<class Key, class Compare, class Allocator>
|
| 179 |
void swap(set<Key, Compare, Allocator>& x,
|
| 180 |
set<Key, Compare, Allocator>& y)
|
| 181 |
noexcept(noexcept(x.swap(y)));
|
| 182 |
}
|