|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.MemoryOptimizedMap<K,V>
public abstract class MemoryOptimizedMap<K,V>
This is a map implementation that is very memory efficient for very small maps. It is based on the observation that for very small maps, the general overhead can accumulate, especially if you have a lot of them. For example, this is the memory usage for some ways to store 2 pointers: Object w/ 2 members: 16 bytes Object[2] : 24 bytes Object w member which is an Object[2]: 40 bytes This map implementation uses a very simple linear search, which should not be an issue for the sizes in this map. The map switches over to a HashMap if it becomes too large. It behaves exactly like a regular map. Note that 2 methods in the EntrySet are not implemented, however those should be rarely used. Generally one needs to be very aware of how these maps are being used, so this class needs to be very carefully applied. Normally if you feel like you should use this class, you probably did something overall wrong, and should redesign your algorithms ...
Constructor Summary | |
---|---|
MemoryOptimizedMap()
|
Method Summary | ||
---|---|---|
void |
clear()
|
|
java.lang.Object |
clone()
|
|
boolean |
containsKey(java.lang.Object key)
|
|
boolean |
containsValue(java.lang.Object value)
|
|
static java.util.Map |
deepOptimize(java.util.Map tab)
|
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns a collection view of the mappings contained in this map. |
|
boolean |
equals(java.lang.Object that)
Returns true iff this is equal to that |
|
V |
get(java.lang.Object key)
|
|
static
|
getOptimizedMap(int size)
|
|
static
|
getOptimizedMap(int size,
boolean growOnly)
|
|
boolean |
isEmpty()
|
|
java.util.Set<K> |
keySet()
Returns a set view of the keys contained in this map. |
|
static
|
optimize(java.util.Map<K,V> tab)
|
|
static
|
optimize(java.util.Map<K,V> tab,
boolean growOnly)
|
|
static void |
optimizeInPlace(java.util.Map s)
|
|
V |
put(K key,
V value)
|
|
void |
putAll(java.util.Map<? extends K,? extends V> t)
|
|
V |
remove(java.lang.Object key)
|
|
int |
size()
|
|
java.lang.String |
toString()
|
|
java.util.Collection<V> |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
hashCode |
Constructor Detail |
---|
public MemoryOptimizedMap()
Method Detail |
---|
public static <K,V> java.util.Map<K,V> getOptimizedMap(int size)
public static <K,V> java.util.Map<K,V> getOptimizedMap(int size, boolean growOnly)
public int size()
size
in interface java.util.Map<K,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<K,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<K,V>
public V put(K key, V value)
put
in interface java.util.Map<K,V>
public V remove(java.lang.Object key)
remove
in interface java.util.Map<K,V>
public void putAll(java.util.Map<? extends K,? extends V> t)
putAll
in interface java.util.Map<K,V>
public void clear()
clear
in interface java.util.Map<K,V>
public static <K,V> java.util.Map<K,V> optimize(java.util.Map<K,V> tab)
public static <K,V> java.util.Map<K,V> optimize(java.util.Map<K,V> tab, boolean growOnly)
public static java.util.Map deepOptimize(java.util.Map tab)
public static void optimizeInPlace(java.util.Map s)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object that)
this
is equal to that
equals
in interface java.util.Map<K,V>
equals
in class java.lang.Object
public java.util.Set<K> keySet()
keySet
in interface java.util.Map<K,V>
public java.util.Collection<V> values()
values
in interface java.util.Map<K,V>
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
Map.Entry
public java.lang.Object clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |