changes from review

This commit is contained in:
ghidravore 2020-06-02 12:58:36 -04:00
parent e3aebe3adb
commit ca58264d65
6 changed files with 41 additions and 277 deletions

View file

@ -105,37 +105,6 @@ public class ObjectCache {
addToHardCache(obj);
}
/**
* Clear both hard and weak caches.
* The cache should be cleared when all cached objects have become invalid.
*/
public synchronized void clear() {
processQueue();
for (KeyedSoftReference<?> ref : hashTable.values()) {
ref.clear();
}
hashTable.clear();
refQueue = new ReferenceQueue<Object>();
}
/**
* Remove the specified range of keyed objects from both hard and weak caches.
* A cache range should be cleared when the corresponding objects have become invalid.
* @param startKey minimum object key value
* @param endKey maximum object key value
*/
public synchronized void remove(long startKey, long endKey) {
if ((endKey >> 1) - (startKey >> 1) < (hashTable.size() >> 1)) {
for (long i = startKey; i <= endKey; i++) {
remove(i);
}
}
else {
hashTable.keySet().removeIf(key -> (key >= startKey && key <= endKey));
}
}
/**
* Remove the specified keyed object from both hard and weak caches.
* An object should be removed from the cache when it becomes invalid.

View file

@ -35,7 +35,7 @@ public class StringAttribute<T extends KeyedObject> extends Attribute<T> {
*/
public StringAttribute(String name, KeyIndexableSet<T> set) {
super(name, set);
this.values = new HashMap<>(set.capacity());// String[set.capacity()];
this.values = new HashMap<>();
}
/** Set the value of this attribute for the specified KeyedObject.