Deque#
Source file#
Interface#
-
template<ContainerElement T>
class Deque# A double-ended queue.
deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both its beginning and its end. In addition, insertion and deletion at either end of a deque never invalidates pointers or references to the rest of the elements.
As opposed to vector, the elements of a deque are not stored contiguously: typical implementations use a sequence of individually allocated fixed-size arrays, with additional bookkeeping, which means indexed access to deque must perform two pointer dereferences, compared to vector’s indexed access which performs only one.
Difference
Allocatoris not required as template parameter.Deafult map size is fixed in
DEQUE_DEFAULT_MAP_SIZE(T), which means more memory is allocated in advance.Deafult subarray size is fixed in
DEQUE_DEFAULT_SUBARRAY_SIZE(T)
- 模板参数
T – Type of the elements stored in the deque.
Public Types
-
using allocator_traits = std::allocator_traits<allocator_type>#
-
using pointer = typename allocator_traits::pointer#
-
using const_pointer = typename allocator_traits::const_pointer#
-
using reference = value_type&#
-
using const_reference = const value_type&#
-
using size_type = std::size_t#
-
using difference_type = std::ptrdiff_t#
-
using const_reverse_iterator = std::reverse_iterator<const_iterator>#
Public Functions
-
Deque()#
-
explicit Deque(size_type count, const T &value = value_type())#
-
~Deque()#
-
Deque &operator=(Deque &&other) noexcept(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value)#
-
allocator_type get_allocator() const noexcept#
-
const_iterator begin() const noexcept#
-
const_iterator end() const noexcept#
-
reverse_iterator rbegin() noexcept#
-
const_reverse_iterator rbegin() const noexcept#
-
reverse_iterator rend() noexcept#
-
const_reverse_iterator rend() const noexcept#
-
const_iterator cbegin() const noexcept#
-
const_iterator cend() const noexcept#
-
const_reverse_iterator crbegin() const noexcept#
-
const_reverse_iterator crend() const noexcept#
-
bool empty() const noexcept#
-
void shrink_to_fit()#
-
const_reference operator[](size_type n) const#
-
const_reference at(size_type n) const#
-
const_reference front() const#
-
const_reference back() const#
-
template<class ...Args>
iterator emplace(const_iterator pos, Args&&... args)#
-
iterator insert(const_iterator pos, const T &value)#
-
iterator insert(const_iterator pos, T &&rvalue)#
-
iterator insert(const_iterator pos, size_type n, const T &value)#
-
template<std::input_iterator InputIt>
iterator insert(const_iterator pos, InputIt first, InputIt last)#
-
iterator insert(const_iterator pos, std::initializer_list<T>)#
-
void pop_front()#
-
void pop_back()#
-
iterator erase(const_iterator pos)#
-
iterator erase(const_iterator first, const_iterator last)#
-
void swap(Deque&) noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value)#
-
void clear() noexcept#