Skip to content

Commit

Permalink
Trie: Add begin memeber function
Browse files Browse the repository at this point in the history
  • Loading branch information
akshitgrover committed May 5, 2019
1 parent bcc9ea0 commit 6788428
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class trie {
void insert(std::string, T);
bool exist(std::string);
bool empty();
iterator begin();
private:
tnode<T>* root;
int size;
Expand Down
7 changes: 7 additions & 0 deletions trie.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <string>

#include "_trie_util.h"
#include "_trie_iterator.h"

template <typename T>
trie<T>::trie(): size(0) {
Expand Down Expand Up @@ -55,3 +56,9 @@ template <typename T>
bool trie<T>::empty() {
return this->size == 0;
}

template <typename T>
typename trie<T>::iterator trie<T>::begin() {
trie_iterator<T> it = *(new trie_iterator<T>(this->root));
return ++it;
}

0 comments on commit 6788428

Please sign in to comment.