Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- iterator begin() {
- Node* cr = this->root;
- bool flag = false;
- while (cr && !flag) {
- if (cr->left && !cr->leftThreaded) {
- cr = cr->left;
- }
- else flag = true;
- }
- return iterator(cr, this);
- }
- /*Returns an iterator to the node that follows the node with the biggest value.*/
- iterator end() {
- return iterator(nullptr, this);
- }
- /*Returns a const_iterator that points to the node with the smallest value.*/
- const_iterator cbegin()const {
- Node* cr = this->root;
- bool flag = false;
- while (cr && !flag) {
- if (cr->left && !cr->leftThreaded) {
- cr = cr->left; //if the node has a left child -> move left
- }
- else flag = true;
- }
- return const_iterator(cr, this);
- }
- /*Returns a const_iterator to the node that follows the node with the biggest value.*/
- const_iterator cend() const {
- return const_iterator(nullptr, this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement