Skip to content
/ trie Public

An implementation of the Trie data structure and a related DataTrie to look up data by string key

License

Notifications You must be signed in to change notification settings

lepoidev/trie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status License FOSSA Status

Summary

This repository contains the implementation of a Trie data structure and a variation called a DataTrie. The DataTrie is a Trie where the nodes which mark the end a string also hold data. This is to provide an alternative to using std::unordered_map or std::map with string keys.

More Info:

Integration

Note that these data sctructures are designed for C++14

Trie

#include <Trie/Trie.h>

Instantiation examples:

Trie< char > charTrie;

Trie< char16_t > char16Trie;

Trie< char32_t > char32Trie;

Trie< wchar_t > wcharTrie;

DataTrie

#include <Trie/DataTrie.h>

Instantiation examples:

struct SomeData
{
  int someVariable;
  // ...
};

DataTrie< char, std::shared_ptr< SomeData > > charDataTrie;

DataTrie< char16_t, SomeData > char16DataTrie;

DataTrie< char32_t, std::function< bool(SomeData const&) > > char32DataTrie;

DataTrie< wchar_t, std::wstring > wcharDataTrie;

Custom

To create a Trie variation:

  1. Create a DerivedTrieNode class which extends TrieNode or DataTrieNode
  2. Create a DerivedTrie class which extends BasicTrie< DerivedTrieNode< ... >, CharTy >
#include <Trie/BasicTrie.h>

Running Tests

$ cmake .
$ cmake --build .
$ ctest -VV --output-on-failure

About

An implementation of the Trie data structure and a related DataTrie to look up data by string key

Topics

Resources

License

Stars

Watchers

Forks