/** * get the index of the item given a key * @param key of the entry * @return the index to be used in the cache */ public final int getIndex(Object key) { return getIndex(hash(key)); }
/** * get the index of the item given a key * @param key of the entry * @return the index to be used in the cache */ public final int getIndex(Object key) { return getIndex(hash(key)); }
/** * get the index of the item given a key * @param key of the entry * @return the index to be used in the cache */ public final int getIndex(Object key) { return getIndex(hash(key)); }
/** * get the index of the item given a key * @param key of the entry * @return the index to be used in the cache */ public final int getIndex(Object key) { return getIndex(hash(key)); }
/** * remove the item stored at the key. * @param item CacheItem to be removed * @return the item stored at the key; null if not found. */ protected CacheItem _removeItem(CacheItem ritem) { int index = getIndex(ritem.hashCode); CacheItem prev = null, item = null; synchronized (bucketLocks[index]) { for (item = buckets[index]; item != null; item = item.next) { if (item == ritem) { if (prev == null) { buckets[index] = item.next; } else { prev.next = item.next; } item.next = null; break; } prev = item; } } if (item != null) { decrementEntryCount(); } return item; }
/** * remove the item stored at the key. * @param item CacheItem to be removed * @return the item stored at the key; null if not found. */ protected CacheItem _removeItem(CacheItem ritem) { int index = getIndex(ritem.hashCode); CacheItem prev = null, item = null; synchronized (bucketLocks[index]) { for (item = buckets[index]; item != null; item = item.next) { if (item == ritem) { if (prev == null) { buckets[index] = item.next; } else { prev.next = item.next; } item.next = null; break; } prev = item; } } if (item != null) { decrementEntryCount(); } return item; }
/** * remove the item stored at the key. * @param item CacheItem to be removed * @return the item stored at the key; null if not found. */ protected CacheItem _removeItem(CacheItem ritem) { int index = getIndex(ritem.hashCode); CacheItem prev = null, item = null; synchronized (bucketLocks[index]) { for (item = buckets[index]; item != null; item = item.next) { if (item == ritem) { if (prev == null) { buckets[index] = item.next; } else { prev.next = item.next; } item.next = null; break; } prev = item; } } if (item != null) { decrementEntryCount(); } return item; }
/** * remove the item stored at the key. * @param item CacheItem to be removed * @return the item stored at the key; null if not found. */ protected CacheItem _removeItem(CacheItem ritem) { int index = getIndex(ritem.hashCode); CacheItem prev = null, item = null; synchronized (bucketLocks[index]) { for (item = buckets[index]; item != null; item = item.next) { if (item == ritem) { if (prev == null) { buckets[index] = item.next; } else { prev.next = item.next; } item.next = null; break; } prev = item; } } if (item != null) { decrementEntryCount(); } return item; }
/** * get all the items stored at the key. * @param key lookup key * @returns an Iterator over the items with the given key. */ public Iterator getAll(Object key) { int hashCode = hash(key); int index = getIndex(hashCode); ArrayList valueList = new ArrayList(entryCount); synchronized (bucketLocks[index]) { CacheItem item = buckets[index]; for (; item != null; item = item.next) { if ( (hashCode == item.hashCode) && eq(key, item.key) ) { incrementHitCount(); valueList.add(item.getValue()); } } } return valueList.iterator(); }
/** * get all the items stored at the key. * @param key lookup key * @returns an Iterator over the items with the given key. */ public Iterator getAll(Object key) { int hashCode = hash(key); int index = getIndex(hashCode); ArrayList valueList = new ArrayList(entryCount); synchronized (bucketLocks[index]) { CacheItem item = buckets[index]; for (; item != null; item = item.next) { if ( (hashCode == item.hashCode) && eq(key, item.key) ) { incrementHitCount(); valueList.add(item.getValue()); } } } return valueList.iterator(); }
/** * get all the items stored at the key. * @param key lookup key * @returns an Iterator over the items with the given key. */ public Iterator getAll(Object key) { int hashCode = hash(key); int index = getIndex(hashCode); ArrayList valueList = new ArrayList(entryCount); synchronized (bucketLocks[index]) { CacheItem item = buckets[index]; for (; item != null; item = item.next) { if ( (hashCode == item.hashCode) && eq(key, item.key) ) { incrementHitCount(); valueList.add(item.getValue()); } } } return valueList.iterator(); }
int index = getIndex(hashCode);
/** * get all the items stored at the key. * @param key lookup key * @returns an Iterator over the items with the given key. */ public Iterator getAll(Object key) { int hashCode = hash(key); int index = getIndex(hashCode); ArrayList valueList = new ArrayList(entryCount); synchronized (bucketLocks[index]) { CacheItem item = buckets[index]; for (; item != null; item = item.next) { if ( (hashCode == item.hashCode) && eq(key, item.key) ) { incrementHitCount(); valueList.add(item.getValue()); } } } return valueList.iterator(); }
int index = getIndex(hashCode);
int index = getIndex(hashCode);
int index = getIndex(hashCode);
int index = getIndex(hashCode); Object value; CacheItem item = null;
int index = getIndex(hashCode); Object value; CacheItem item = null;
int index = getIndex(hashCode); Object value; CacheItem item = null;
int index = getIndex(hashCode); Object value; CacheItem item = null;