org.gudy.azureus2.core3.util
Class LightHashMap<S,T>

java.lang.Object
  extended by java.util.AbstractMap<S,T>
      extended by org.gudy.azureus2.core3.util.LightHashMap<S,T>
All Implemented Interfaces:
Cloneable, Map<S,T>
Direct Known Subclasses:
JSONObject, LightHashMapEx

public class LightHashMap<S,T>
extends AbstractMap<S,T>
implements Cloneable

A lighter (on memory) hash map
Advantages over HashMap:

Disadvantages:

Author:
Aaron Grunthal

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
LightHashMap()
           
LightHashMap(int initialCapacity)
           
LightHashMap(int initialCapacity, float loadFactor)
           
LightHashMap(Map m)
           
 
Method Summary
 int capacity()
           
 void clear()
           
 Object clone()
           
 void compactify(float compactingLoadFactor)
          will shrink the internal storage size to the least possible amount, should be used after removing many entries for example
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
           
 T get(Object key)
           
 Set<S> keySet()
           
static void main(String[] args)
           
 T put(Object key, Object value)
           
 void putAll(Map m)
           
 T remove(Object key)
           
 Collection<T> values()
           
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, size, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LightHashMap

public LightHashMap()

LightHashMap

public LightHashMap(int initialCapacity)

LightHashMap

public LightHashMap(Map m)

LightHashMap

public LightHashMap(int initialCapacity,
                    float loadFactor)
Method Detail

clone

public Object clone()
Overrides:
clone in class AbstractMap<S,T>

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map<S,T>
Specified by:
entrySet in class AbstractMap<S,T>

put

public T put(Object key,
             Object value)
Specified by:
put in interface Map<S,T>
Overrides:
put in class AbstractMap<S,T>

putAll

public void putAll(Map m)
Specified by:
putAll in interface Map<S,T>
Overrides:
putAll in class AbstractMap<S,T>

keySet

public Set<S> keySet()
Specified by:
keySet in interface Map<S,T>
Overrides:
keySet in class AbstractMap<S,T>

values

public Collection<T> values()
Specified by:
values in interface Map<S,T>
Overrides:
values in class AbstractMap<S,T>

capacity

public int capacity()

get

public T get(Object key)
Specified by:
get in interface Map<S,T>
Overrides:
get in class AbstractMap<S,T>

remove

public T remove(Object key)
Specified by:
remove in interface Map<S,T>
Overrides:
remove in class AbstractMap<S,T>

clear

public void clear()
Specified by:
clear in interface Map<S,T>
Overrides:
clear in class AbstractMap<S,T>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<S,T>
Overrides:
containsKey in class AbstractMap<S,T>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<S,T>
Overrides:
containsValue in class AbstractMap<S,T>

compactify

public void compactify(float compactingLoadFactor)
will shrink the internal storage size to the least possible amount, should be used after removing many entries for example

Parameters:
compactingLoadFactor - load factor for the compacting operation. Use 0f to compact with the load factor specified during instantiation. Use negative values of the desired load factors to compact only when it would reduce the storage size.

main

public static void main(String[] args)