Skip to content

Commit

Permalink
Trie: Add rend member function
Browse files Browse the repository at this point in the history
  • Loading branch information
akshitgrover committed May 5, 2019
1 parent f71e32b commit 9075305
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class trie {
iterator begin();
iterator end();
iterator rbegin();
iterator rend();
private:
tnode<T>* root;
int size;
Expand Down
11 changes: 11 additions & 0 deletions trie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,14 @@ typename trie<T>::iterator trie<T>::rbegin() {
trie_iterator<T> it = *(new trie_iterator<T>(t));
return it;
}

template <typename T>
typename trie<T>::iterator trie<T>::rend() {
T flag;
tnode<T>* r = nullptr;
if (!this->empty()) {
r = recur(this->root);
}
tnode<T>* t = new tnode<T>(flag, r, -1516);
return *(new trie_iterator<T>(t));
}

0 comments on commit 9075305

Please sign in to comment.