tire.h 752 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __L87_TIRE_H__
  2. #define __L87_TIRE_H__
  3. #include "list.h"
  4. #include "list.cpp"
  5. #include <string>
  6. template<typename Type,
  7. typename Container = List<Type>>
  8. class Tire {
  9. public:
  10. struct Node {
  11. Node();
  12. Node(Type& value);
  13. Node* operator[](const int ch);
  14. Node* _next[256] { nullptr };
  15. typename Container::Node* _value = nullptr;
  16. };
  17. typedef typename Container::iterator iterator;
  18. private:
  19. Node _root;
  20. Container _container;
  21. public:
  22. Tire();
  23. Type& operator[](const std::string& key);
  24. iterator find(const std::string& key);
  25. iterator insert(const std::string& key, Type& value);
  26. iterator erase(const std::string& key);
  27. public:
  28. iterator begin();
  29. iterator end();
  30. iterator rbegin();
  31. iterator rend();
  32. };
  33. #endif