|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<Long,V>
com.devexperts.util.AbstractLongMap<V>
com.devexperts.util.LongHashMap<V>
public final class LongHashMap<V>
Hashtable based implementation of the LongMap
interface. This
implementation provides all of the optional map operations, and permits
null values. This class makes no guarantees as to
the order of the map; in particular, it does not guarantee that the order
will remain constant over time.
Note that this implementation is not synchronized. If multiple
threads access this map concurrently, and at least one of the threads
modifies the map structurally, it must be synchronized externally.
(A structural modification is any operation that adds or deletes one or
more mappings; merely changing the value associated with a key that an
instance already contains is not a structural modification.) This is
typically accomplished by synchronizing on some object that naturally
encapsulates the map. If no such object exists, the map should be
"wrapped" using the Collections.synchronizedMap(java.util.Map
method.
This is best done at creation time, to prevent accidental unsynchronized
access to the map.
The iterators returned by all of this class's "collection view methods" are
fail-fast: if the map is structurally modified at any time after the
iterator is created, in any way except through the iterator's own
remove or add methods, the iterator will throw a
ConcurrentModificationException
. Thus, in the face of
concurrent modification, the iterator fails quickly and cleanly, rather
than risking arbitrary, non-deterministic behavior at an undetermined time
in the future.
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 com.devexperts.util.LongMap |
---|
LongMap.Entry<V> |
Field Summary | |
---|---|
static int |
MAX_CAPACITY
Maximal supported capacity of this hashtable. |
Constructor Summary | |
---|---|
LongHashMap()
Constructs a new, empty map. |
|
LongHashMap(int capacity)
Constructs a new map with a specified capacity. |
|
LongHashMap(Map<? extends Long,? extends V> m)
Constructs a new map containing all mappings from the specified map. |
Method Summary | |
---|---|
void |
clear()
|
void |
clearAndCompact()
Removes all mappings and frees all memory. |
void |
clearAndCompact(int capacity)
Removes all mappings and compacts memory usage of this hashtable, but requested capacity is retained. |
Object |
clone()
Returns a shallow copy of this LongHashMap instance:
the values themselves are not cloned. |
void |
compact()
Compacts memory usage of this hashtable. |
void |
compact(int capacity)
Compacts memory usage of this hashtable, but requested capacity is retained. |
boolean |
containsKey(long key)
Returns true if this map contains a mapping for the specified key. |
void |
ensureCapacity(int capacity)
Makes sure that no rehashes or memory reallocations will be needed until size() <= capacity . |
Set<Map.Entry<Long,V>> |
entrySet()
Returns a collection view of the mappings contained in this map. |
V |
get(long key)
Returns the value to which this map maps the specified key. |
boolean |
isEmpty()
|
LongSet |
longKeySet()
Returns a set view of the keys contained in this map. |
V |
put(long key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(Map<? extends Long,? extends V> t)
|
V |
remove(long key)
Removes the mapping for this key from this map if present. |
int |
size()
|
Collection<V> |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class com.devexperts.util.AbstractLongMap |
---|
containsKey, get, keySet, put, remove |
Methods inherited from class java.util.AbstractMap |
---|
containsValue, equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsValue, equals, hashCode |
Field Detail |
---|
public static final int MAX_CAPACITY
Constructor Detail |
---|
public LongHashMap()
public LongHashMap(Map<? extends Long,? extends V> m)
public LongHashMap(int capacity)
Method Detail |
---|
public int size()
size
in interface Map<Long,V>
size
in class AbstractLongMap<V>
public boolean isEmpty()
isEmpty
in interface Map<Long,V>
isEmpty
in class AbstractMap<Long,V>
public void clear()
clear
in interface Map<Long,V>
clear
in class AbstractLongMap<V>
public void putAll(Map<? extends Long,? extends V> t)
putAll
in interface Map<Long,V>
putAll
in class AbstractMap<Long,V>
public boolean containsKey(long key)
LongMap
containsKey
in interface LongMap<V>
containsKey
in class AbstractLongMap<V>
Map.containsKey(Object)
public V get(long key)
LongMap
get
in interface LongMap<V>
get
in class AbstractLongMap<V>
Map.get(Object)
public V put(long key, V value)
LongMap
put
in interface LongMap<V>
put
in class AbstractLongMap<V>
Map.put(Object, Object)
public V remove(long key)
LongMap
remove
in interface LongMap<V>
remove
in class AbstractLongMap<V>
Map.remove(Object)
public LongSet longKeySet()
LongHashSet
.
longKeySet
in interface LongMap<V>
longKeySet
in class AbstractLongMap<V>
Map.keySet()
public Collection<V> values()
values
in interface Map<Long,V>
values
in class AbstractLongMap<V>
public Set<Map.Entry<Long,V>> entrySet()
LongMap.Entry
. The
collection is backed by the map, so changes to the map are reflected in
the collection, and vice-versa. The collection supports element
removal, which removes the corresponding mapping from the map, via the
Iterator.remove, Collection.remove,
removeAll, retainAll, and clear operations.
It does not support the add or addAll operations.
entrySet
in interface Map<Long,V>
entrySet
in class AbstractLongMap<V>
LongMap.Entry
public void ensureCapacity(int capacity)
size() <= capacity
.
IllegalArgumentException
- when capacity > MAX_CAPACITY
.public void compact()
public void compact(int capacity)
compact()
and ensureCapacity(int)
calls,
but is faster, because it does not produce excessive garbage.
When capacity is less or equal than 1, this method is equivalent
to compact()
.
IllegalArgumentException
- when capacity > MAX_CAPACITY
.public void clearAndCompact()
clear()
and compact()
calls,
but is faster.
public void clearAndCompact(int capacity)
clear()
and compact(int)
calls,
but is faster. When capacity is less or equal than 1, this method is
equivalent to clearAndCompact()
.
IllegalArgumentException
- when capacity > MAX_CAPACITY
.public Object clone()
LongHashMap
instance:
the values themselves are not cloned.
clone
in class AbstractMap<Long,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |