Deleted Added
sdiff udiff text old ( 12334:e0ab29a34764 ) new ( 12335:4a2fde008219 )
full compact
1/*
2 * Copyright (c) 2012 Google
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 18 unchanged lines hidden (view full) ---

27 *
28 * Authors: Gabe Black
29 */
30
31#ifndef __BASE_TRIE_HH__
32#define __BASE_TRIE_HH__
33
34#include <cassert>
35
36#include "base/cprintf.hh"
37#include "base/logging.hh"
38#include "base/types.hh"
39
40// Key has to be an integral type.
41template <class Key, class Value>
42class Trie

--- 34 unchanged lines hidden (view full) ---

77 if (kids[0]) {
78 kids[0]->clear();
79 delete kids[0];
80 kids[0] = NULL;
81 }
82 }
83
84 void
85 dump(int level)
86 {
87 for (int i = 1; i < level; i++) {
88 cprintf("|");
89 }
90 if (level == 0)
91 cprintf("Root ");
92 else
93 cprintf("+ ");
94 cprintf("(%p, %p, %#X, %#X, %p)\n", parent, this, key, mask, value);
95 if (kids[0])
96 kids[0]->dump(level + 1);
97 if (kids[1])
98 kids[1]->dump(level + 1);
99 }
100 };
101
102 protected:
103 Node head;
104
105 public:
106 typedef Node *Handle;

--- 239 unchanged lines hidden (view full) ---

346 head.clear();
347 }
348
349 /**
350 * A debugging method which prints the contents of this trie.
351 * @param title An identifying title to put in the dump header.
352 */
353 void
354 dump(const char *title)
355 {
356 cprintf("**************************************************\n");
357 cprintf("*** Start of Trie: %s\n", title);
358 cprintf("*** (parent, me, key, mask, value pointer)\n");
359 cprintf("**************************************************\n");
360 head.dump(0);
361 }
362};
363
364#endif