1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include "ResultCache.h"
#include <map>
#include <iostream>
using namespace std;
typedef map<unsigned, unsigned> ResultCacheMap;
typedef ResultCacheMap::value_type ResultCacheLine;
ResultCacheMap rescache;
ResultCache cache;
bool ResultCache::find(unsigned s, unsigned *r) {
ResultCacheMap::const_iterator res = rescache.find(s);
if (res != rescache.end()) {
*r = (*res).second;
return true;
}
return false;
}
void ResultCache::insert(unsigned s, unsigned r) {
rescache.insert(ResultCacheLine(s,r));
}
|