size [C++ Reference]
Keywords: stl,deque,size
Date: 2009-08-06T06:26:26-0700

[[size]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## size

Syntax:

        #include <deque>
        size_type size() const;

The size function returns the number of elements in the current deque.

For example:

        deque<int> myints;
        cout << "initial size: " << myints.size() << '\n';

        for( int i = 0; i < 5; ++i ) myints.push_back(i);
        cout << "after five additions: " << myints.size() << '\n';

        myints.insert( myints.begin(), 5, 100 );
        cout << "after five insertions: " << myints.size() << '\n';

        myints.pop_back();
        cout << "after a removal: " << myints.size() << '\n';

The above code produces the following output:

        initial size: 0
        after five additions: 5
        after five insertions: 10
        after a removal: 9

Related Topics: max_size, resize

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •