tmp/tmp09s1oopn/{from.md → to.md}
RENAMED
|
@@ -1,29 +1,28 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
A `deque` is a sequence container that supports random access iterators
|
| 4 |
-
|
| 5 |
insert and erase operations at the beginning or the end; insert and
|
| 6 |
erase in the middle take linear time. That is, a deque is especially
|
| 7 |
optimized for pushing and popping elements at the beginning and end.
|
| 8 |
Storage management is handled automatically.
|
| 9 |
|
| 10 |
-
A `deque`
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
requirements
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
information.
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
namespace std {
|
| 21 |
template<class T, class Allocator = allocator<T>>
|
| 22 |
class deque {
|
| 23 |
public:
|
| 24 |
-
// types
|
| 25 |
using value_type = T;
|
| 26 |
using allocator_type = Allocator;
|
| 27 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 28 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 29 |
using reference = value_type&;
|
|
@@ -57,11 +56,11 @@ namespace std {
|
|
| 57 |
void assign(InputIterator first, InputIterator last);
|
| 58 |
void assign(size_type n, const T& t);
|
| 59 |
void assign(initializer_list<T>);
|
| 60 |
allocator_type get_allocator() const noexcept;
|
| 61 |
|
| 62 |
-
// iterators
|
| 63 |
iterator begin() noexcept;
|
| 64 |
const_iterator begin() const noexcept;
|
| 65 |
iterator end() noexcept;
|
| 66 |
const_iterator end() const noexcept;
|
| 67 |
reverse_iterator rbegin() noexcept;
|
|
@@ -73,18 +72,18 @@ namespace std {
|
|
| 73 |
const_iterator cend() const noexcept;
|
| 74 |
const_reverse_iterator crbegin() const noexcept;
|
| 75 |
const_reverse_iterator crend() const noexcept;
|
| 76 |
|
| 77 |
// [deque.capacity], capacity
|
| 78 |
-
bool
|
| 79 |
size_type size() const noexcept;
|
| 80 |
size_type max_size() const noexcept;
|
| 81 |
void resize(size_type sz);
|
| 82 |
void resize(size_type sz, const T& c);
|
| 83 |
void shrink_to_fit();
|
| 84 |
|
| 85 |
-
// element access
|
| 86 |
reference operator[](size_type n);
|
| 87 |
const_reference operator[](size_type n) const;
|
| 88 |
reference at(size_type n);
|
| 89 |
const_reference at(size_type n) const;
|
| 90 |
reference front();
|
|
@@ -117,29 +116,15 @@ namespace std {
|
|
| 117 |
void swap(deque&)
|
| 118 |
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 119 |
void clear() noexcept;
|
| 120 |
};
|
| 121 |
|
| 122 |
-
template<class InputIterator,
|
| 123 |
-
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 124 |
deque(InputIterator, InputIterator, Allocator = Allocator())
|
| 125 |
-
-> deque<
|
| 126 |
|
| 127 |
-
|
| 128 |
-
bool operator==(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 129 |
-
template <class T, class Allocator>
|
| 130 |
-
bool operator< (const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 131 |
-
template <class T, class Allocator>
|
| 132 |
-
bool operator!=(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 133 |
-
template <class T, class Allocator>
|
| 134 |
-
bool operator> (const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 135 |
-
template <class T, class Allocator>
|
| 136 |
-
bool operator>=(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 137 |
-
template <class T, class Allocator>
|
| 138 |
-
bool operator<=(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
|
| 139 |
-
|
| 140 |
-
// [deque.special], specialized algorithms
|
| 141 |
template<class T, class Allocator>
|
| 142 |
void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
|
| 143 |
noexcept(noexcept(x.swap(y)));
|
| 144 |
}
|
| 145 |
```
|
|
|
|
| 1 |
+
#### Overview <a id="deque.overview">[[deque.overview]]</a>
|
| 2 |
|
| 3 |
A `deque` is a sequence container that supports random access iterators
|
| 4 |
+
[[random.access.iterators]]. In addition, it supports constant time
|
| 5 |
insert and erase operations at the beginning or the end; insert and
|
| 6 |
erase in the middle take linear time. That is, a deque is especially
|
| 7 |
optimized for pushing and popping elements at the beginning and end.
|
| 8 |
Storage management is handled automatically.
|
| 9 |
|
| 10 |
+
A `deque` meets all of the requirements of a container, of a reversible
|
| 11 |
+
container (given in tables in [[container.requirements]]), of a
|
| 12 |
+
sequence container, including the optional sequence container
|
| 13 |
+
requirements [[sequence.reqmts]], and of an allocator-aware container (
|
| 14 |
+
[[container.alloc.req]]). Descriptions are provided here only for
|
| 15 |
+
operations on `deque` that are not described in one of these tables or
|
| 16 |
+
for operations where there is additional semantic information.
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
namespace std {
|
| 20 |
template<class T, class Allocator = allocator<T>>
|
| 21 |
class deque {
|
| 22 |
public:
|
| 23 |
+
// types
|
| 24 |
using value_type = T;
|
| 25 |
using allocator_type = Allocator;
|
| 26 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 27 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 28 |
using reference = value_type&;
|
|
|
|
| 56 |
void assign(InputIterator first, InputIterator last);
|
| 57 |
void assign(size_type n, const T& t);
|
| 58 |
void assign(initializer_list<T>);
|
| 59 |
allocator_type get_allocator() const noexcept;
|
| 60 |
|
| 61 |
+
// iterators
|
| 62 |
iterator begin() noexcept;
|
| 63 |
const_iterator begin() const noexcept;
|
| 64 |
iterator end() noexcept;
|
| 65 |
const_iterator end() const noexcept;
|
| 66 |
reverse_iterator rbegin() noexcept;
|
|
|
|
| 72 |
const_iterator cend() const noexcept;
|
| 73 |
const_reverse_iterator crbegin() const noexcept;
|
| 74 |
const_reverse_iterator crend() const noexcept;
|
| 75 |
|
| 76 |
// [deque.capacity], capacity
|
| 77 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 78 |
size_type size() const noexcept;
|
| 79 |
size_type max_size() const noexcept;
|
| 80 |
void resize(size_type sz);
|
| 81 |
void resize(size_type sz, const T& c);
|
| 82 |
void shrink_to_fit();
|
| 83 |
|
| 84 |
+
// element access
|
| 85 |
reference operator[](size_type n);
|
| 86 |
const_reference operator[](size_type n) const;
|
| 87 |
reference at(size_type n);
|
| 88 |
const_reference at(size_type n) const;
|
| 89 |
reference front();
|
|
|
|
| 116 |
void swap(deque&)
|
| 117 |
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 118 |
void clear() noexcept;
|
| 119 |
};
|
| 120 |
|
| 121 |
+
template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
|
|
|
|
| 122 |
deque(InputIterator, InputIterator, Allocator = Allocator())
|
| 123 |
+
-> deque<iter-value-type<InputIterator>, Allocator>;
|
| 124 |
|
| 125 |
+
// swap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
template<class T, class Allocator>
|
| 127 |
void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
|
| 128 |
noexcept(noexcept(x.swap(y)));
|
| 129 |
}
|
| 130 |
```
|