Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xorz57/trie
Trie written in C++14
https://github.com/xorz57/trie
cpp data-structures datastructures trie
Last synced: about 2 months ago
JSON representation
Trie written in C++14
- Host: GitHub
- URL: https://github.com/xorz57/trie
- Owner: xorz57
- License: mit
- Created: 2023-08-01T13:04:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-17T09:12:28.000Z (11 months ago)
- Last Synced: 2024-03-17T10:27:18.013Z (11 months ago)
- Topics: cpp, data-structures, datastructures, trie
- Language: C++
- Homepage: https://xorz57.github.io/Trie
- Size: 191 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Trie
[![Build](https://github.com/xorz57/Trie/actions/workflows/Build.yml/badge.svg)](https://github.com/xorz57/Trie/actions/workflows/Build.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xorz57_Trie&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=xorz57_Trie)## Example
```cpp
#include "Trie/Trie.hpp"#include
int main() {
trie_t trie;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;
}
```## How to Build
#### Linux & macOS
```bash
git clone https://github.com/microsoft/vcpkg.git ~/vcpkg
~/vcpkg/bootstrap-vcpkg.shgit 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
```powershell
git clone https://github.com/microsoft/vcpkg.git C:/vcpkg
C:/vcpkg/bootstrap-vcpkg.bat
C:/vcpkg/vcpkg.exe integrate installgit 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
```