Trie
Loading...
Searching...
No Matches
Trie

Build Quality Gate Status

Example

#include "Trie/Trie.hpp"
#include <iostream>
int main() {
trie.insert("apple");
trie.insert("app");
if (trie.search("apple")) {
std::cout << "Search 'apple': True" << std::endl;
} else {
std::cout << "Search 'apple': False" << std::endl;
}
if (trie.search("app")) {
std::cout << "Search 'app': True" << std::endl;
} else {
std::cout << "Search 'app': False" << std::endl;
}
if (trie.search("ap")) {
std::cout << "Search 'ap': True" << std::endl;
} else {
std::cout << "Search 'ap': False" << std::endl;
}
if (trie.starts_with("app")) {
std::cout << "Starts with 'app': True" << std::endl;
} else {
std::cout << "Starts with 'app': False" << std::endl;
}
if (trie.starts_with("bat")) {
std::cout << "Starts with 'bat': True" << std::endl;
} else {
std::cout << "Starts with 'bat': False" << std::endl;
}
return 0;
}
Definition: Trie.hpp:30
bool search(const std::basic_string< T > &word)
Definition: Trie.hpp:45
bool starts_with(const std::basic_string< T > &prefix)
Definition: Trie.hpp:56
void insert(const std::basic_string< T > &word)
Definition: Trie.hpp:34

How to Build

Linux & macOS

git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
~/vcpkg/bootstrap-vcpkg.sh
git clone https://github.com/xorz57/Trie.git
cd Trie
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release

Windows

git clone https://github.com/microsoft/vcpkg.git C:/vcpkg
C:/vcpkg/bootstrap-vcpkg.bat
C:/vcpkg/vcpkg.exe integrate install
git clone https://github.com/xorz57/Trie.git
cd Trie
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --build-config Release