diff --git a/TinySTL/Detail/TireTree.cpp b/TinySTL/Detail/TireTree.cpp index fdf84e00b979a6b6fde78b565f1c13aa72fef714..2ff57f17500c78f520500bbf6505852982e54650 100644 --- a/TinySTL/Detail/TireTree.cpp +++ b/TinySTL/Detail/TireTree.cpp @@ -1,11 +1,11 @@ #include "../TrieTree.h" namespace TinySTL{ - trie_tree::trie_tree():data(new trie_node), size_(0){} + trie_tree::trie_tree() :root_(new trie_node), size_(0){} trie_tree::~trie_tree(){ - if (data){ - data->map_childs.clear(); - delete data; + if (root_){ + root_->map_childs.clear(); + delete root_; } } bool trie_tree::empty()const{ diff --git a/TinySTL/TrieTree.h b/TinySTL/TrieTree.h index 5f2bf3dd6111641acca90cefc6602791f0091ef8..e91f859318a955ae154414a5de52adf771ad474f 100644 --- a/TinySTL/TrieTree.h +++ b/TinySTL/TrieTree.h @@ -24,7 +24,7 @@ namespace TinySTL{ typedef string value_type; typedef size_t size_type; private: - trie_node *data; + trie_node *root_; size_type size_; public: trie_tree(); @@ -41,7 +41,7 @@ namespace TinySTL{ bool is_existed(const string& word)const; private: node_ptr make_node(char ch, bool is_a_word); - inline trie_node* get_root()const{ return data; } + inline trie_node* get_root()const{ return root_; } void _get_word_by_prefix(const string& prefix, const node_ptr& up, const string& real_prefix, vector& words)const; void __get_word_by_prefix(const node_ptr& up, string& word, const string& prefix, vector& words)const; void _print_tree(std::ostream& os, const node_ptr& up, string word)const;