diff options
author | Adrian Kummerländer | 2014-02-04 19:10:11 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2014-02-04 19:10:11 +0100 |
commit | 8d1661ea333f15ddc2dde3b2a25288d1ccf485d9 (patch) | |
tree | 77137bc4739d5c18272cc30ee96bf6969626ab70 | |
parent | e0028fb5303218feebe61b2cd93d4601c40fde79 (diff) | |
download | Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.gz Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.bz2 Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.lz Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.xz Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.tar.zst Trie-8d1661ea333f15ddc2dde3b2a25288d1ccf485d9.zip |
Moved Trie template into src directory
* renamed trie.cc to test.cc in preparation for implementing GoogleTest based test cases
-rw-r--r-- | src/trie.h (renamed from trie.cc) | 27 | ||||
-rw-r--r-- | test.cc | 24 |
2 files changed, 28 insertions, 23 deletions
@@ -1,10 +1,9 @@ -#include <cstdint> +#ifndef TRIE_SRC_TRIE_H_ +#define TRIE_SRC_TRIE_H_ + #include <vector> #include <map> -#include <cassert> -#include <iostream> - template < typename Key > @@ -92,22 +91,4 @@ class Trie { }; -int main() { - Trie<uint8_t> test; - - test.add({1, 2, 3}); - test.add({1, 2, 4}); - test.add({2, 1}); - test.add({2, 1, 1}); - - assert(test.resolve({1, 2}).second != nullptr); - assert(test.resolve({1, 2, 3}).second != nullptr); - assert(test.resolve({1, 2, 4}).second != nullptr); - assert(test.resolve({3}).second == nullptr); - - test.remove({1, 2}); - - assert(test.resolve({1, 2, 4}).second == nullptr); - assert(test.resolve({1, 2, 3}).second == nullptr); - assert(test.resolve({1, 2}).second == nullptr); -} +#endif // TRIE_SRC_TRIE_H_ @@ -0,0 +1,24 @@ +#include "trie.h" + +#include <cassert> +#include <cstdint> + +int main() { + Trie<uint8_t> test; + + test.add({1, 2, 3}); + test.add({1, 2, 4}); + test.add({2, 1}); + test.add({2, 1, 1}); + + assert(test.resolve({1, 2}).second != nullptr); + assert(test.resolve({1, 2, 3}).second != nullptr); + assert(test.resolve({1, 2, 4}).second != nullptr); + assert(test.resolve({3}).second == nullptr); + + test.remove({1, 2}); + + assert(test.resolve({1, 2, 4}).second == nullptr); + assert(test.resolve({1, 2, 3}).second == nullptr); + assert(test.resolve({1, 2}).second == nullptr); +} |