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