1 30 31 32 package org.hsqldb.store; 33 34 import org.hsqldb.lib.Collection; 35 import org.hsqldb.lib.Iterator; 36 import org.hsqldb.lib.Set; 37 38 45 public class ObjectCacheHashMap extends BaseHashMap { 46 47 Set keySet; 48 Collection values; 49 50 public ObjectCacheHashMap(int initialCapacity) 51 throws IllegalArgumentException { 52 super(initialCapacity, 1, BaseHashMap.intKeyOrValue, 53 BaseHashMap.objectKeyOrValue, true); 54 } 55 56 public Object get(int key) { 57 58 if (accessCount == Integer.MAX_VALUE) { 59 resetAccessCount(); 60 } 61 62 int lookup = getLookup(key); 63 64 if (lookup == -1) { 65 return null; 66 } 67 68 accessTable[lookup] = accessCount++; 69 70 return objectValueTable[lookup]; 71 } 72 73 public Object put(int key, Object value) { 74 75 if (accessCount == Integer.MAX_VALUE) { 76 resetAccessCount(); 77 } 78 79 return super.addOrRemove(key, value, false); 80 } 81 82 public Object remove(int key) { 83 return super.addOrRemove(key, null, true); 84 } 85 86 90 public int getAccessCountCeiling(int count, int margin) { 91 return super.getAccessCountCeiling(count, margin); 92 } 93 94 98 public void setAccessCountFloor(int count) { 99 super.accessMin = count; 100 } 101 102 public ObjectCacheIterator iterator() { 103 return new ObjectCacheIterator(); 104 } 105 106 public class ObjectCacheIterator extends BaseHashIterator 107 implements Iterator {} 108 } 109 | Popular Tags |