本文主要是介绍STL 双端队列,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
template<class T, class A = allocator<T> >
class deque {
public://类型定义typedef A allocator_type;typedef A::size_type size_type;typedef A::difference_type difference_type;typedef A::reference reference;typedef A::const_reference const_reference;typedef A::value_type value_type;typedef T0 iterator;typedef T1 const_iterator;typedef reverse_iterator<iterator, value_type,reference, A::pointer, difference_type>reverse_iterator;typedef reverse_iterator<const_iterator, value_type,const_reference, A::const_pointer, difference_type>const_reverse_iterator;//构造函数explicit deque(const A& al = A());explicit deque(size_type n, const T& v = T(), const A& al = A());deque(const deque& x);deque(const_iterator first, const_iterator last,const A& al = A());//返回第一个开始元素迭代iterator begin();const_iterator begin() const;//返回结束尾后元素迭代器iterator end();iterator end() const;//返回反向开始元素迭代reverse_iterator rbegin();const_reverse_iterator rbegin() const;//返回反向尾后迭代reverse_iterator rend();const_reverse_iterator rend() const;//中心分配大小void resize(size_type n, T x = T());//返回元素个数size_type size() const;//返回元素最大容量size_type max_size() const;//如果队列为空返回falsebool empty() const;A get_allocator() const;//获取指定位置元素reference at(size_type pos);const_reference at(size_type pos) const;//重载[]运算符reference operator[](size_type pos);const_reference operator[](size_type pos);//返回首元素引用reference front();const_reference front() const;//返回尾元素引用reference back();const_reference back() const;//队头压入元素void push_front(const T& x);//队头弹出元素void pop_front();//队尾压入元素void push_back(const T& x);//队尾弹出元素void pop_back();//清空原队列,根据指定容器进行void assign(const_iterator first, const_iterator last);void assign(size_type n, const T& x = T());//插入元素iterator insert(iterator it, const T& x = T());void insert(iterator it, size_type n, const T& x);void insert(iterator it,const_iterator first, const_iterator last);//删除元素iterator erase(iterator it);iterator erase(iterator first, iterator last);//清空void clear();//交换void swap(deque x);
protected:A allocator;
};
这篇关于STL 双端队列的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!