If your iterator is not bidirectional, you don't need an end to point to anything (just use NULL in this case). end()you only need to have real value in the case of a bidirectional iterator, because in this case you will need to move back from end()the top of the list.
The GNU C ++ library (what you get if you use std::mapwith GCC / g ++) implements end()as a pointer to the root of the node tree. Thus, if it is used in a bidirectional iterator, you can access the root file of the node to find the largest node in the tree (this is the node immediately before end()).
Change the explanation of an empty tree
node ( , node). , node node ( end()). begin() , end().
, - :
template<class T> struct node_t {
T data;
node_t *left;
node_t *right;
};
template<class T> class map {
private:
node_t root;
public:
iterator begin() { return iterator(root.left); }
iterator end() { return iterator(&root); }
}