begin
Syntax:
#include <set> iterator begin(); const_iterator begin() const; The function begin() returns an iterator to the first element of the set. begin() should run in constant time. For example, the following code uses begin() to initialize an iterator that is used to traverse a list: // Create a list of characters list<char> charList; for( int i=0; i < 10; i++ ) { charList.push_front( i + 65 ); } // Display the list list<char>::iterator theIterator; for( theIterator = charList.begin(); theIterator != charList.end(); theIterator++ ) { cout << *theIterator; } |
#include <set> void clear();
The function clear() deletes all of the elements in the set. clear() runs in linear time.