queue::size | public member function |
size_type size ( ) const; |
Return size
Returns the number of elements in the queue.
This member function effectively calls the member with the same name in the underlying container object.
Parameters
noneReturn Value
The number of elements that conform the queue's container content.Member type size_type is an unsigned integral type.
Example
// queue::size #include <iostream> #include <queue> using namespace std; int main () { queue<int> myints; cout << "0. size: " << (int) myints.size() << endl; for (int i=0; i<5; i++) myints.push(i); cout << "1. size: " << (int) myints.size() << endl; myints.pop(); cout << "2. size: " << (int) myints.size() << endl; return 0; } |
Output:
0. size: 0 |
Complexity
Constant.See also
queue::empty | Test whether container is empty (public member function) |