I was wondering how would the iterators set in c++'s STL works. I guess the set is implemented using binary search tree, that means the iterators does inorder traversal of this tree. But my question is that,when does they do this traversing, at the very beginning when we do like it= s.begin() and store the traversed pointers in kind of stack internally and refer only this data structure on every increment in the iterator or the increment in the iterator does a new inorder traversal on the tree.
I mean when we initialize like
set<int> s;
set<int>::iterator it;
//and then use it like:
for(it = s.begin(); it!=s.end(); )
{
dosth();
++it; // does this do a inorder traversal of the tree again to find the next
// node or it gets the next node in the tree by reading the internal
// data structure(of inorder traversal) which is created when we do s.begin().
}