Class deque

Synopsis

#include <include/EASTL/deque.h>

template <typename T, typename Allocator = EASTLAllocatorType, unsigned kDequeSubarraySize = DEQUE_DEFAULT_SUBARRAY_SIZE(T)>
class deque : public DequeBase<T, Allocator, kDequeSubarraySize>

Description

deque

Implements a conventional C++ double-ended queue. The implementation used here is very much like any other deque implementations you may have seen, as it follows the standard algorithm for deque design.

Note: As of this writing, deque does not support zero-allocation initial emptiness. A newly created deque with zero elements will still allocate a subarray pointer set. We are looking for efficient and clean ways to get around this, but current efforts have resulted in less efficient and more fragile code. The logic of this class doesn't lend itself to a clean implementation. It turns out that deques are one of the least likely classes you'd want this behaviour in, so until this functionality becomes very important to somebody, we will leave it as-is. It can probably be solved by adding some extra code to the Do* functions and adding good comments explaining the situation.

Mentioned in

Inheritance

Ancestors: DequeBase

Methods

deque overloaddeque
~deque
assign overloadIt turns out that the C++ std::deque specifies a two argument version of assign that takes (int size, int value)
at overload
back overload
begin overloaditerators, so we need to do a template compiler trick to do the right thing.
cbegin
cend
clear
crbegin
crend
DoAllocatePtrArray
DoAllocateSubarray
DoAssign overload
DoAssignValues
DoFillInit
DoFreePtrArray
DoFreeSubarray
DoFreeSubarrays
DoInit overload
DoInitFromIterator overload
DoInsert overload
DoInsertFromIterator
DoInsertValues
DoReallocPtrArray
DoReallocSubarray
DoSwap
emplace
emplace_back
emplace_front
empty
end overload
erase overload
front overload
insert overload
operator= overload
operator[] overload
pop_back
pop_front
push_back overload

Mentioned in

push_front overload

Mentioned in

rbegin overload
rend overload
resize overload
set_capacity
shrink_to_fit
size

Mentioned in

swap// The reset_lose_memory function is a special extension function which unilaterally // resets the container to an empty state without freeing the memory of // the contained objects
validate
validate_iterator

Source

Lines 336-510 in include/EASTL/deque.h.

template <typename T, typename Allocator = EASTLAllocatorType, unsigned kDequeSubarraySize = DEQUE_DEFAULT_SUBARRAY_SIZE(T)>
class deque : public DequeBase<T, Allocator, kDequeSubarraySize>
{
public:
    typedef DequeBase<T, Allocator, kDequeSubarraySize>              base_type;
    typedef deque<T, Allocator, kDequeSubarraySize>                  this_type;
    typedef T                                                        value_type;
    typedef T*                                                       pointer;
    typedef const T*                                                 const_pointer;
    typedef T&                                                       reference;
    typedef const T&                                                 const_reference;
    typedef DequeIterator<T, T*, T&, kDequeSubarraySize>             iterator;
    typedef DequeIterator<T, const T*, const T&, kDequeSubarraySize> const_iterator;
    typedef eastl::reverse_iterator<iterator>                        reverse_iterator;
    typedef eastl::reverse_iterator<const_iterator>                  const_reverse_iterator;
    typedef typename base_type::size_type                            size_type;
    typedef typename base_type::difference_type                      difference_type;
    typedef typename base_type::allocator_type                       allocator_type;
    using base_type::kSideFront;
    using base_type::kSideBack;
    using base_type::mpPtrArray;
    using base_type::mnPtrArraySize;
    using base_type::mItBegin;
    using base_type::mItEnd;
    using base_type::mAllocator;
    using base_type::npos;
    using base_type::DoAllocateSubarray;
    using base_type::DoFreeSubarray;
    using base_type::DoFreeSubarrays;
    using base_type::DoAllocatePtrArray;
    using base_type::DoFreePtrArray;
    using base_type::DoReallocSubarray;
    using base_type::DoReallocPtrArray;
public:
    deque();
    explicit deque(const allocator_type& allocator);
    explicit deque(size_type n, const allocator_type& allocator = EASTL_DEQUE_DEFAULT_ALLOCATOR);
    deque(size_type n, const value_type& value, const allocator_type& allocator = EASTL_DEQUE_DEFAULT_ALLOCATOR);
    deque(const this_type& x);
    deque(this_type&& x);
    deque(this_type&& x, const allocator_type& allocator);
    deque(std::initializer_list<value_type> ilist, const allocator_type& allocator = EASTL_DEQUE_DEFAULT_ALLOCATOR);
    template <typename InputIterator>
    deque(InputIterator first, InputIterator last); // allocator arg removed because VC7.1 fails on the default arg. To do: Make a second version of this function without a default arg.
   ~deque();
    this_type& operator=(const this_type& x);
    this_type& operator=(std::initializer_list<value_type> ilist);
    this_type& operator=(this_type&& x);
    void swap(this_type& x);
    void assign(size_type n, const value_type& value);
    void assign(std::initializer_list<value_type> ilist);
    template <typename InputIterator>                       // It turns out that the C++ std::deque<int, int> specifies a two argument
    void assign(InputIterator first, InputIterator last);   // version of assign that takes (int size, int value). These are not 
                                                            // iterators, so we need to do a template compiler trick to do the right thing.
    iterator       begin() EA_NOEXCEPT;
    const_iterator begin() const EA_NOEXCEPT;
    const_iterator cbegin() const EA_NOEXCEPT;
    iterator       end() EA_NOEXCEPT;
    const_iterator end() const EA_NOEXCEPT;
    const_iterator cend() const EA_NOEXCEPT;
    reverse_iterator       rbegin() EA_NOEXCEPT;
    const_reverse_iterator rbegin() const EA_NOEXCEPT;
    const_reverse_iterator crbegin() const EA_NOEXCEPT;
    reverse_iterator       rend() EA_NOEXCEPT;
    const_reverse_iterator rend() const EA_NOEXCEPT;
    const_reverse_iterator crend() const EA_NOEXCEPT;
    bool      empty() const EA_NOEXCEPT; 
    size_type size() const EA_NOEXCEPT;
    void resize(size_type n, const value_type& value);
    void resize(size_type n);
    void shrink_to_fit();
    void set_capacity(size_type n = base_type::npos);
    reference       operator[](size_type n);
    const_reference operator[](size_type n) const;
    reference       at(size_type n);
    const_reference at(size_type n) const;
    reference       front();
    const_reference front() const;
    reference       back();
    const_reference back() const;
    void      push_front(const value_type& value);
    reference push_front();
    void      push_front(value_type&& value);
    void      push_back(const value_type& value);
    reference push_back();
    void      push_back(value_type&& value);
    void pop_front();
    void pop_back();
    template<class... Args>
    iterator emplace(const_iterator position, Args&&... args);
    template<class... Args>
    void emplace_front(Args&&... args);
    template<class... Args>
    void emplace_back(Args&&... args);
    iterator insert(const_iterator position, const value_type& value);
    iterator insert(const_iterator position, value_type&& value);
    void     insert(const_iterator position, size_type n, const value_type& value);
    iterator insert(const_iterator position, std::initializer_list<value_type> ilist);
    template <typename InputIterator>
    void insert(const_iterator position, InputIterator first, InputIterator last);
    iterator         erase(const_iterator position);
    iterator         erase(const_iterator first, const_iterator last);
    reverse_iterator erase(reverse_iterator position);
    reverse_iterator erase(reverse_iterator first, reverse_iterator last);
    void clear();
    //void reset_lose_memory(); // Disabled until it can be implemented efficiently and cleanly.  // This is a unilateral reset to an initially empty state. No destructors are called, no deallocation occurs.
    bool validate() const;
    int  validate_iterator(const_iterator i) const;
protected:
    template <typename Integer>
    void DoInit(Integer n, Integer value, true_type);
    template <typename InputIterator>
    void DoInit(InputIterator first, InputIterator last, false_type);
    template <typename InputIterator>
    void DoInitFromIterator(InputIterator first, InputIterator last, EASTL_ITC_NS::input_iterator_tag);
    template <typename ForwardIterator>
    void DoInitFromIterator(ForwardIterator first, ForwardIterator last, EASTL_ITC_NS::forward_iterator_tag);
    void DoFillInit(const value_type& value);
    template <typename Integer>
    void DoAssign(Integer n, Integer value, true_type);
    template <typename InputIterator>
    void DoAssign(InputIterator first, InputIterator last, false_type);
    void DoAssignValues(size_type n, const value_type& value);
    template <typename Integer>
    void DoInsert(const const_iterator& position, Integer n, Integer value, true_type);
    template <typename InputIterator>
    void DoInsert(const const_iterator& position, const InputIterator& first, const InputIterator& last, false_type);
    template <typename InputIterator>
    void DoInsertFromIterator(const_iterator position, const InputIterator& first, const InputIterator& last, EASTL_ITC_NS::forward_iterator_tag);
    void DoInsertValues(const_iterator position, size_type n, const value_type& value);
    void DoSwap(this_type& x);
}; // class deque





Add Discussion as Guest

Log in