=====begin=====
Syntax:
#include
iterator begin();
const_iterator begin() const;
The function begin() returns an iterator to the first element of the multiset.
begin() should run in [[/complexity|constant time]].
For example, the following code uses begin() to initialize an iterator that is
used to traverse the elements of a multiset:
multiset ms;
multiset::iterator iter;
int i;
for (i = 1; i < 5; i++) {
ms.insert(i);
ms.insert(i*i);
ms.insert(i-1);
}
cout << "ms is:" ;
for (iter = ms.begin(); iter != ms.end(); iter++)
cout << " " << *iter;
cout << "." << endl;
The above code produces the following output:
ms is: 0 1 1 1 2 2 3 3 4 4 9 16.
Related Topics: [[end]], [[rbegin]], [[rend]]