| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2024 Muhammad Nawaz | ||
| 3 | * Licensed under the MIT License. See LICENSE file for more information. | ||
| 4 | */ | ||
| 5 | // [ END OF LICENSE c6bd0f49d040fca8d8a9cb05868e66aa63f0e2e0 ] | ||
| 6 | |||
| 7 | #ifndef PATH_TRIE_HPP | ||
| 8 | #define PATH_TRIE_HPP | ||
| 9 | |||
| 10 | #include "utils/common.hpp" | ||
| 11 | #include <string> | ||
| 12 | #include <unordered_map> | ||
| 13 | |||
| 14 | class PathTrie | ||
| 15 | { | ||
| 16 | public: | ||
| 17 | PathTrie(); | ||
| 18 | PathTrie(const PathTrie& other); // Copy constructor | ||
| 19 | PathTrie& operator=(const PathTrie& other); // Copy assignment operator | ||
| 20 | ~PathTrie(); | ||
| 21 | |||
| 22 | void Insert(const std::string& path); | ||
| 23 | bool Search(const char* beg, const char* end, std::string& oas_path); | ||
| 24 | bool Search(const char* beg, const char* end, std::string& oas_path, | ||
| 25 | std::unordered_map<size_t, ParamRange>& param_idxs); | ||
| 26 | |||
| 27 | private: | ||
| 28 | struct Node | ||
| 29 | { | ||
| 30 | 503 | Node() = default; | |
| 31 | std::string dir{}; | ||
| 32 | bool is_param = false; | ||
| 33 | int frag_idx = 0; | ||
| 34 | std::unordered_map<std::string, Node*> children{}; | ||
| 35 | }; | ||
| 36 | |||
| 37 | void DeleteNode(Node* node); | ||
| 38 | void CopyNode(Node*& this_node, Node* other_node); | ||
| 39 | |||
| 40 | Node* root_; | ||
| 41 | }; | ||
| 42 | |||
| 43 | #endif // PATH_TRIE_HPP | ||
| 44 |