| 52 | |
| 53 | template<class KeyClass, class ValueClass> |
| 54 | bool Cache<KeyClass, ValueClass>::hasKey (const KeyClass& key) const |
| 55 | { |
| 56 | _itKey = _key.end(); // referring to past-the-end element in the list |
| 57 | typename std::list<KeyClass>::const_iterator itKey; |
| 58 | _itValue = _value.begin(); |
| 59 | /* As _key is a sorted list, the following could actually be implemented |
| 60 | in logarithmic time, by bisection. However, for lists this does not work. |
| 61 | But often, we can still terminate the linear loop before having visited |
| 62 | all elements. */ |
| 63 | for (itKey = _key.begin(); itKey != _key.end(); itKey++) |
| 64 | { |
| 65 | int c = key.compare(*itKey); |
| 66 | if (c == 0) |
| 67 | { |
| 68 | _itKey = itKey; |
| 69 | return true; |
| 70 | } |
| 71 | if (c == -1) return false; |
| 72 | _itValue++; |
| 73 | } |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | template<class KeyClass, class ValueClass> |
| 78 | ValueClass Cache<KeyClass, ValueClass>::getValue (const KeyClass& /*key*/) const |
no test coverage detected