Ejemplo n.º 1
0
bool Compare(const CacheMap<int,int>& map1, const CacheMap<int,int>& map2 )
{
    if(map1.GetMaxSize() != map2.GetMaxSize()) {
        return false;
    }

    if(map1.GetSize() != map2.GetSize()) {
        return false;
    }

    const CacheMap<int,int>::list_t& items1 = map1.GetItemList();
    for(CacheMap<int,int>::list_cit it = items1.begin(); it != items1.end(); ++it) {
        if(!map2.HasKey(it->key)) {
            return false;
        }
        int val = 0;
        if(!map2.Get(it->key, val)) {
            return false;
        }
        if(it->value != val) {
            return false;
        }
    }

    const CacheMap<int,int>::list_t& items2 = map2.GetItemList();
    for(CacheMap<int,int>::list_cit it = items2.begin(); it != items2.end(); ++it) {
        if(!map1.HasKey(it->key)) {
            return false;
        }
        int val = 0;
        if(!map1.Get(it->key, val)) {
            return false;
        }
        if(it->value != val) {
            return false;
        }
    }

    return true;
}