#ifndef PREFIX_TREE_HH #define PREFIX_TREE_HH #include #include #include #include namespace prefix_tree { class Builder { public: virtual ~Builder() = default; virtual void add(std::string_view str) = 0; [[nodiscard]] virtual std::optional build() const = 0; protected: Builder() = default; Builder(Builder const&) = delete; Builder& operator=(Builder const&) = delete; }; [[nodiscard]] std::unique_ptr builder(); // Returns the length of the prefix of str that exists in tree. // Returns nullopt if prefix of str doesn't match any string in tree. [[nodiscard]] std::optional lookup(std::string_view tree, std::string_view str); } // namespace prefix_tree #endif // PREFIX_TREE_HH