SoftwareIntrospectionLab / FixCache

Other
16 stars 5 forks source link

Is CacheItem Iterator working as expected? #39

Open cflewis opened 13 years ago

cflewis commented 13 years ago

In Cache.java, there's this bit of code:

// used in file distribution output
@Override
public Iterator<CacheItem> iterator() {
    return cacheTable.values().iterator();
}

This will return the contents of cacheTable, but my understanding is that the contents of cacheTable does not necessarily reflect the contents of the cache. Shouldn't the items be checked for isInCache before they are returned?

If not, is this iterator safe to use if I want to output the contents of the cache at the end of the simulation?

xyzhu commented 13 years ago

I think this should be checked. Because when we remove an item from cache, we do not really remove it, instead we just set its "inCache" to be false. So at last, only cache items with inCache being true reflect the content of the cache.