begin [C++ Reference]
Keywords: stl,deque,begin
Date: 2009-08-05T01:58:57-0700

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

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

## begin

Syntax:

        #include <deque>
        iterator begin();
        const_iterator begin() const;

The function begin() returns an iterator to the first element of the deque. begin() should run in constant time.

For example, the following code uses begin() to initialize an iterator that is used to traverse a deque:

         // Create a deque of characters
         deque<char> dq_char;
         for( int i=0; i < 10; i++ ) {
           dq_char.push_front( i + 'a' );
         }
         // Display the deque
         deque<char>::iterator theIterator;
         for( theIterator = dq_char.begin(); theIterator != dq_char.end(); theIterator++ ) {
           cout << *theIterator;
         }

The code produces the following output:

     abcdefghij

Related Topics: end, rbegin, rend

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