fork download
  1. #ifndef DICT_H
  2. #define DICT_H
  3.  
  4. #include <fstream>
  5. #include <string>
  6.  
  7. const int MAX_CAPACITY=100;
  8. // The structure of a dictionary entry
  9. class DictEntry {
  10. public:
  11. DictEntry(std::string, int);
  12. friend std::ostream &operator <<(std::ostream &os, const DictEntry &entry);
  13. std::string key;
  14. int value;
  15. };
  16.  
  17. class Dict {
  18. friend std::ostream &operator <<(std::ostream &os, const Dict &dictionary);
  19. public:
  20. Dict();
  21. Dict(int);
  22. Dict(const Dict &other);
  23. ~Dict();
  24. Dict &operator =(const Dict &other);
  25. int get(std::string key) const;
  26. void put(std::string key, int value);
  27. int getSize() const {return size;}
  28. bool contains(std::string key) const;
  29. void sortByKey();
  30. void sortByValue();
  31. private:
  32. int find(std::string key) const;
  33. void checkCapacity();
  34. DictEntry *entries;
  35. int size, capacity;
  36. };
  37.  
  38. #endif
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty