org.webmacro.util
Class SimpleHashMap
java.lang.Object
|
+--org.webmacro.util.SimpleHashMap
- All Implemented Interfaces:
- SimpleMap
- public final class SimpleHashMap
- extends java.lang.Object
- implements SimpleMap
This map has a fixed number of buckets. Each bucket is an LRU
cache. The map never increases the number of buckets once it has
been created. The advantage is that it synchronizes on the bucket
so multiple threads can access the map simultaneously without
blocking, providing they access different buckets.
Constructor Summary |
SimpleHashMap()
Create a new SimpleMap with 1001 LRU buckets |
SimpleHashMap(int size)
Create a new SimpleMap with 'size' LRU buckets |
Method Summary |
void |
clear()
|
java.lang.Object |
get(java.lang.Object key)
Get the value of 'key' back. |
java.util.Iterator |
iterator()
Returns an iterator that will walk along a snapshot of the keys of
this SimpleMap. |
static void |
main(java.lang.String[] arg)
|
void |
put(java.lang.Object key,
java.lang.Object value)
Add a key to the SimpleMap. |
java.lang.Object |
remove(java.lang.Object key)
Ensure that the key does not appear in the map |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleHashMap
public SimpleHashMap()
- Create a new SimpleMap with 1001 LRU buckets
SimpleHashMap
public SimpleHashMap(int size)
- Create a new SimpleMap with 'size' LRU buckets
put
public void put(java.lang.Object key,
java.lang.Object value)
- Add a key to the SimpleMap.
- Specified by:
put
in interface SimpleMap
get
public java.lang.Object get(java.lang.Object key)
- Get the value of 'key' back. Returns null if no such key.
- Specified by:
get
in interface SimpleMap
remove
public java.lang.Object remove(java.lang.Object key)
- Ensure that the key does not appear in the map
- Specified by:
remove
in interface SimpleMap
clear
public void clear()
- Specified by:
clear
in interface SimpleMap
iterator
public java.util.Iterator iterator()
- Returns an iterator that will walk along a snapshot of the keys of
this SimpleMap. If the Map changes during the creation of this
iterator some values may be missed or included twice, but otherwise
it will work. The remove() method on this iterator is well defined.
main
public static void main(java.lang.String[] arg)