cached_shortest_sequences.h 734 B

1234567891011121314151617181920212223242526272829
  1. #ifndef CACHED_SHORTEST_SEQUENCES_H
  2. #define CACHED_SHORTEST_SEQUENCES_H
  3. #include <map>
  4. #include <vector>
  5. #include <string_view>
  6. #include <optional>
  7. #include <functional>
  8. #include "segmented_sequences.h"
  9. class CachedShortestSequences {
  10. private:
  11. std::map<std::string, std::shared_ptr<SegmentedSequences>> cache_;
  12. std::map<const SegmentedSequences *, std::shared_ptr<SegmentedSequences>>
  13. segmented_cache_;
  14. public:
  15. std::shared_ptr<SegmentedSequences> Find(
  16. std::string_view code,
  17. std::function<std::optional<char>(char, char)> apply_cmd);
  18. std::shared_ptr<SegmentedSequences> Find(
  19. std::shared_ptr<SegmentedSequences> codes,
  20. std::function<std::optional<char>(char, char)> apply_cmd);
  21. };
  22. #endif