MCPcopy Create free account
hub / github.com/apache/trafficserver / Search

Method Search

include/tscore/Trie.h:188–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186
187template <typename T>
188T *
189Trie<T>::Search(const char *key, int key_len /* = -1 */) const
190{
191 _CheckArgs(key, key_len);
192
193 const Node *found_node = nullptr;
194 const Node *curr_node = &m_root;
195 int i = 0;
196
197 while (curr_node) {
198 if (dbg_ctl_search.on()) {
199 DbgPrint(dbg_ctl_search, "Visiting node...");
200 curr_node->Print(dbg_ctl_search);
201 }
202 if (curr_node->occupied) {
203 if (!found_node || curr_node->rank <= found_node->rank) {
204 found_node = curr_node;
205 }
206 }
207 if (i == key_len) {
208 break;
209 }
210 curr_node = curr_node->GetChild(key[i]);
211 ++i;
212 }
213
214 if (found_node) {
215 Dbg(dbg_ctl_search, "Returning element with rank %d", found_node->rank);
216 return found_node->value;
217 }
218
219 return nullptr;
220}
221
222template <typename T>
223void

Callers

nothing calls this directly

Calls 3

GetChildMethod · 0.80
onMethod · 0.45
PrintMethod · 0.45

Tested by

no test coverage detected