Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
deque
comparison operators
deque::deque
deque::~deque
member functions:
deque::assign
deque::at
deque::back
deque::begin
deque::clear
deque::empty
deque::end
deque::erase
deque::front
deque::get_allocator
deque::insert
deque::max_size
deque::operator=
deque::operator[]
deque::pop_back
deque::pop_front
deque::push_back
deque::push_front
deque::rbegin
deque::rend
deque::resize
deque::size
deque::swap


deque::size

public member function
size_type size() const;

Return size

Returns the number of elements in the deque container.

Parameters

none

Return Value

The number of elements that conform the deque container's content.

Member type size_type is an unsigned integral type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// deque::size
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  deque<int> myints;
  cout << "0. size: " << (int) myints.size() << endl;
  for (int i=0; i<5; i++) myints.push_back(i);
  cout << "1. size: " << (int) myints.size() << endl;
  myints.insert (myints.begin(),5,100);
  cout << "2. size: " << (int) myints.size() << endl;
  myints.pop_back();
  cout << "3. size: " << (int) myints.size() << endl;
  return 0;
}


Output:
0. size: 0
1. size: 5
2. size: 10
3. size: 9

Complexity

Constant.

See also