当前位置: 首页 > 文档资料 > C/C++ 语言参考 >

C++ Double-Ended Queues

优质
小牛编辑
141浏览
2023-12-01

Operators

Syntax:
  []

You can access individual members of the double-ended queue using the [] operator.


assign

Syntax:
  void assign( input_iterator start, input_iterator end);
  void assign( Size num, const TYPE &val );

The function assign() sets the double-ended queue the sequence denoted bystart andend, or setsnum elements toval.


at

Syntax:
  reference at( size_type pos );

The at() function returns a reference to the element atpos in the double-ended queue.


back

Syntax:
  reference back();

The function back() returns a reference to the back element of the double-ended queue.


begin

Syntax:
  iterator begin();

The begin() function returns an iterator to the front element of the double-ended queue.


clear

Syntax:
  void clear();

The clear() function deletes all of the elements from the double-ended queue.


empty

Syntax:
  bool empty();

The function empty() returnstrue if the double-ended queue is empty, andfalse otherwise.


end

Syntax:
  iterator end();

The end() function returns an iterator to the back of the double-ended queue.


erase

Syntax:
  iterator erase( iterator pos );
  iterator erase( iterator start, iterator end );

The function erase() erases the element at locationpos, or the items betweenstart andend. The return value is an iterator to the element just after the last one erased.


front

Syntax:
  reference front();

The front() function returns a reference to the element at the beginning of the double-ended queue.


get_allocator

Syntax:
  allocator_type get_allocator();

The get_allocator() function returns the double-ended queue's allocator.


insert

Syntax:
  iterator insert( iterator pos, size_type num, const TYPE &val );
  void insert( iterator pos, input_iterator start, input_iterator end );

The insert() function insertsnum copies ofval before the element atpos, or inserts the sequence specified bystart andend before the element atpos.


max_size

Syntax:
  size_type max_size();

The function max_size() returns the maximum number of items that the double-ended queue can hold.


pop_back

Syntax:
  void pop_back();

The pop_back() function removes the last element from the double-ended queue.


pop_front

Syntax:
  void pop_front();

The function pop_front() removes the first element from the double-ended queue.


push_back

Syntax:
  void push_back( const TYPE &val );

The push_back() function addsval to the end of the double-ended queue.


push_front

Syntax:
  void push_front( const TYPE &val );

The function push_front() addsval to the front of the double-ended queue.


rbegin

Syntax:
  reverse_iterator rbegin();

The rbegin() function returns a reverse iterator to the back of the double-ended queue.


rend

Syntax:
  reverse_iterator rend();

The function rend() returns a reverse iterator to the front of the double-ended queue.


resize

Syntax:
  void resize( size_type num, TYPE val );

The resize() function changes the size of the double-ended queue tonum, padding any added entries with elements equal toval.


size

Syntax:
  size_type size();

The size() function returns the number of elements in the double-ended queue.


swap

Syntax:
  void swap( dequeue &target );

The swap() function swaps the elements in the current double-ended queue with those intarget.