claw 1.9.0
 
Loading...
Searching...
No Matches
trie.hpp
Go to the documentation of this file.
1/*
2 CLAW - a C++ Library Absolutely Wonderful
3
4 CLAW is a free library without any particular aim but being useful to
5 anyone.
6
7 Copyright (C) 2005-2011 Julien Jorge
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23 contact: julien.jorge@stuff-o-matic.com
24*/
30#ifndef __CLAW_TRIE_HPP__
31#define __CLAW_TRIE_HPP__
32
33#include <claw/binary_node.hpp>
34#include <functional>
35#include <list>
36
37namespace claw
38{
39
62 template <class T, class Comp = std::equal_to<T> >
63 class trie
64 {
65 private:
66 //************************ trie::trie_node ********************************
67
74 struct trie_node : public binary_node<trie_node>
75 {
77 T value;
82 unsigned int count;
83
84 trie_node(const T& val, unsigned int c = 0);
85 trie_node(const trie_node& that);
86
87 }; // trie_node;
88
89 public:
90 //****************************** trie *************************************
91
92 typedef const T value_type;
93 typedef Comp value_equal_to;
94
95 private:
96 typedef trie_node* trie_node_ptr;
97
98 public:
99 trie();
100 trie(const trie<T, Comp>& that);
101 ~trie();
102
103 unsigned int size() const;
104 bool empty() const;
105
106 void clear();
107
108 template <class InputIterator>
109 void insert(InputIterator first, InputIterator last);
110
111 template <class InputIterator>
112 unsigned int count(InputIterator first, InputIterator last);
113
114 private:
116 static value_equal_to s_value_equal_to;
117
119 trie_node_ptr m_tree;
120
122 unsigned int m_size;
123 }; // class trie
124
125}
126
127#include <claw/trie.tpp>
128
129#endif // __CLAW_TRIE_HPP__
Basic binary node.
Basic binary node.
Fuction object to get the first element of a std::pair.
This is the main namespace.