Top Description Inners Fields Constructors Methods
io.netty.util.collection

public Class LongObjectHashMap<V>

extends Object
implements LongObjectMap<V>
Class Inheritance
All Implemented Interfaces
io.netty.util.collection.LongObjectMap, java.util.Map
Type Parameters
<V>
The value type stored in the map.
Static Imports
io.netty.util.internal.MathUtil.safeFindNextPositivePowerOfTwo

A hash map implementation of LongObjectMap that uses open addressing for keys. To minimize the memory footprint, this class uses open addressing rather than chaining. Collisions are resolved using linear probing. Deletions implement compaction, so cost of remove can approach O(N) for full maps, which makes a small loadFactor recommended.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
LongObjectHashMap.EntrySet

Set implementation for iterating over the entries of the map.

private class
LongObjectHashMap.KeySet

Set implementation for iterating over the keys.

pack-priv class
LongObjectHashMap.MapEntry

A single entry in the map.

private class
LongObjectHashMap.MapIterator

Iterator used by the Map interface.

private class
LongObjectHashMap.PrimitiveIterator

Iterator over primitive entries.

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_CAPACITY

Default initial capacity.

public static final float
DEFAULT_LOAD_FACTOR

Default load factor.

private final Iterable<LongObjectMap.PrimitiveEntry<V>>
private final Set<Map.Entry<Long, V>>
private long[]
private final Set<Long>
private final float
loadFactor

The load factor for the map.

private int
private int
maxSize

The maximum number of elements allowed without allocating more space.

private static final Object
NULL_VALUE

Placeholder for null values, so we can use the actual null to mean available.

private int
private V[]

Constructor Summary

AccessConstructor and Description
public
public
LongObjectHashMap(int initialCapacity)

public
LongObjectHashMap(int initialCapacity, float loadFactor)

Method Summary

Modifier and TypeMethod and Description
private int
calcMaxSize(int capacity)

Calculates the maximum size allowed before rehashing.

public void
clear()

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).
public boolean
containsKey(long key)

Implements io.netty.util.collection.LongObjectMap.containsKey.

Indicates whether or not this map contains a value for the specified key.
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.
public Iterable<LongObjectMap.PrimitiveEntry<V>>
entries()

Implements io.netty.util.collection.LongObjectMap.entries.

Gets an iterable to traverse over the primitive entries contained in this map.
public Set<Map.Entry<Long, V>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public boolean
equals(Object
object to be compared for equality with this map
obj
)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.
public V
get(long
the key whose associated value is to be returned.
key
)

Implements io.netty.util.collection.LongObjectMap.get.

Gets the value in the map with the specified key.
public V
get(Object
the key whose associated value is to be returned
key
)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
private void
growSize()

Grows the map size after an insertion.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
private static int
hashCode(long key)

Returns the hash code for the key.

private int
hashIndex(long key)

Returns the hashed index for the given key.

private int

Returns:

the index where the key was found, or -1 if no entry is found for that key.
indexOf
(long
the key for an entry in the map.
key
)

Locates the index for the given key.

public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.
public Set<Long>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
protected String
keyToString(long key)

Helper method called by toString() in order to convert a single map key into a string.

private long
private int
probeNext(int index)

Get the next sequential index after index and wraps if necessary.

public V
put(long
the key of the entry.
key
,
V
the value of the entry.
value
)

Implements io.netty.util.collection.LongObjectMap.put.

Puts the given entry into the map.
public V
put(Long
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public void
putAll(Map<? extends Long, ? extends V>
mappings to be stored in this map
sourceMap
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
private void
rehash(int
the new capacity for the map.
newCapacity
)

Rehashes the map for the given capacity.

public V
remove(long
the key for the entry to be removed from this map.
key
)

Implements io.netty.util.collection.LongObjectMap.remove.

Removes the entry with the specified key.
public V
remove(Object
key whose mapping is to be removed from the map
key
)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
private boolean

Returns:

true if the next item was moved back. false otherwise.
removeAt
(final int
the index position of the element to remove.
index
)

Removes entry at the given index position.

public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
private static <T> T
toExternal(T value)

private static <T> T
toInternal(T value)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<V>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait