multimap.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --- sword-1.6.2/include/multimapwdef.h 2004-05-04 23:01:39.000000000 +0200
  2. +++ /usr/include/sword/multimapwdef.h 2012-06-02 13:37:47.816457345 +0200
  3. @@ -7,26 +7,26 @@
  4. // multmap that still lets you use [] to reference FIRST
  5. // entry of a key if multiples exist
  6. -template <class Key, class T, class Compare>
  7. -class multimapwithdefault : public std::multimap<Key, T, Compare> {
  8. +template < class Key, class T, class Compare >
  9. +class multimapwithdefault : public std::multimap< Key, T, Compare > {
  10. public:
  11. - typedef std::pair<const Key, T> value_type;
  12. + typedef std::pair< const Key, T > value_type;
  13. T& getWithDefault(const Key& k, const T& defaultValue) {
  14. - if (find(k) == this->end()) {
  15. - insert(value_type(k, defaultValue));
  16. + if (this->find(k) == this->end()) {
  17. + this->insert(value_type(k, defaultValue));
  18. }
  19. return (*(find(k))).second;
  20. }
  21. T& operator[](const Key& k) {
  22. - if (find(k) == this->end()) {
  23. - insert(value_type(k, T()));
  24. + if (this->find(k) == this->end()) {
  25. + this->insert(value_type(k, T()));
  26. }
  27. - return (*(find(k))).second;
  28. + return (*(this->find(k))).second;
  29. }
  30. bool has(const Key& k, const T &val) const {
  31. - typename std::multimap<Key, T, Compare>::const_iterator start = lower_bound(k);
  32. - typename std::multimap<Key, T, Compare>::const_iterator end = upper_bound(k);
  33. + typename std::multimap< Key, T, Compare >::const_iterator start = this->lower_bound(k);
  34. + typename std::multimap< Key, T, Compare >::const_iterator end = this->upper_bound(k);
  35. for (; start!=end; start++) {
  36. if (start->second == val)
  37. return true;