[deque.overview] (original) (raw)
In addition, it supports constant time insert and erase operations at the beginning or the end; insert and erase in the middle take linear time.
That is, a deque is especially optimized for pushing and popping elements at the beginning and end.
Storage management is handled automatically.
Descriptions are provided here only for operations ondequethat are not described in one of these tables or for operations where there is additional semantic information.
namespace std { template<class T, class Allocator = allocator<T>> class deque { public: using value_type = T;using allocator_type = Allocator;using pointer = typename allocator_traits<Allocator>::pointer;using const_pointer = typename allocator_traits<Allocator>::const_pointer;using reference = value_type&;using const_reference = const value_type&;using size_type = implementation-defined; using difference_type = implementation-defined; using iterator = implementation-defined; using const_iterator = implementation-defined; using reverse_iterator = std::reverse_iterator<iterator>;using const_reverse_iterator = std::reverse_iterator<const_iterator>;constexpr deque() : deque(Allocator()) { } constexpr explicit deque(const Allocator&);constexpr explicit deque(size_type n, const Allocator& = Allocator());constexpr deque(size_type n, const T& value, const Allocator& = Allocator());template<class InputIterator> constexpr deque(InputIterator first, InputIterator last, const Allocator& = Allocator());template<container-compatible-range<T> R> constexpr deque(from_range_t, R&& rg, const Allocator& = Allocator());constexpr deque(const deque& x);constexpr deque(deque&&);constexpr deque(const deque&, const type_identity_t<Allocator>&);constexpr deque(deque&&, const type_identity_t<Allocator>&);constexpr deque(initializer_list<T>, const Allocator& = Allocator());constexpr ~deque();constexpr deque& operator=(const deque& x);constexpr deque& operator=(deque&& x) noexcept(allocator_traits<Allocator>::is_always_equal::value);constexpr deque& operator=(initializer_list<T>);template<class InputIterator> constexpr void assign(InputIterator first, InputIterator last);template<container-compatible-range<T> R> constexpr void assign_range(R&& rg);constexpr void assign(size_type n, const T& t);constexpr void assign(initializer_list<T>);constexpr allocator_type get_allocator() const noexcept;constexpr iterator begin() noexcept;constexpr const_iterator begin() const noexcept;constexpr iterator end() noexcept;constexpr const_iterator end() const noexcept;constexpr reverse_iterator rbegin() noexcept;constexpr const_reverse_iterator rbegin() const noexcept;constexpr reverse_iterator rend() noexcept;constexpr const_reverse_iterator rend() const noexcept;constexpr const_iterator cbegin() const noexcept;constexpr const_iterator cend() const noexcept;constexpr const_reverse_iterator crbegin() const noexcept;constexpr const_reverse_iterator crend() const noexcept;constexpr bool empty() const noexcept;constexpr size_type size() const noexcept;constexpr size_type max_size() const noexcept;constexpr void resize(size_type sz);constexpr void resize(size_type sz, const T& c);constexpr void shrink_to_fit();constexpr reference operator[](size_type n);constexpr const_reference operator[](size_type n) const;constexpr reference at(size_type n);constexpr const_reference at(size_type n) const;constexpr reference front();constexpr const_reference front() const;constexpr reference back();constexpr const_reference back() const;template<class... Args> constexpr reference emplace_front(Args&&... args);template<class... Args> constexpr reference emplace_back(Args&&... args);template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);constexpr void push_front(const T& x);constexpr void push_front(T&& x);template<container-compatible-range<T> R> constexpr void prepend_range(R&& rg);constexpr void push_back(const T& x);constexpr void push_back(T&& x);template<container-compatible-range<T> R> constexpr void append_range(R&& rg);constexpr iterator insert(const_iterator position, const T& x);constexpr iterator insert(const_iterator position, T&& x);constexpr iterator insert(const_iterator position, size_type n, const T& x);template<class InputIterator> constexpr iterator insert(const_iterator position, InputIterator first, InputIterator last);template<container-compatible-range<T> R> constexpr iterator insert_range(const_iterator position, R&& rg);constexpr iterator insert(const_iterator position, initializer_list<T>);constexpr void pop_front();constexpr void pop_back();constexpr iterator erase(const_iterator position);constexpr iterator erase(const_iterator first, const_iterator last);constexpr void swap(deque&) noexcept(allocator_traits<Allocator>::is_always_equal::value);constexpr void clear() noexcept;};template<class InputIterator, class Allocator = allocator<_iter-value-type_<InputIterator>>> deque(InputIterator, InputIterator, Allocator = Allocator()) -> deque<_iter-value-type_<InputIterator>, Allocator>;template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>> deque(from_range_t, R&&, Allocator = Allocator()) -> deque<ranges::range_value_t<R>, Allocator>;}