Top Description Inners Fields Constructors Methods
com.carrotsearch.hppc

public Class LongObjectHashMap<VType>

extends Object
implements LongObjectMap<VType>, Preallocable, Cloneable, Accountable
Class Inheritance
All Implemented Interfaces
com.carrotsearch.hppc.Accountable, java.lang.Cloneable, com.carrotsearch.hppc.Preallocable, com.carrotsearch.hppc.LongObjectMap, com.carrotsearch.hppc.LongObjectAssociativeContainer, java.lang.Iterable
Annotations
@SuppressWarnings:unchecked
@Generated:KTypeVTypeHashMap.java
date:2024-06-04T15:20:17+0200
Static Imports
com.carrotsearch.hppc.Containers.*, com.carrotsearch.hppc.HashContainers.*

A hash map of long to Object, implemented using open addressing with linear probing for collision resolution. Supports null values.
See Also
HPPC interfaces diagram

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
LongObjectHashMap.EntryIterator

An iterator implementation for iterator.

public class
LongObjectHashMap.KeysContainer

A view of the keys inside this hash map.

private class
LongObjectHashMap.KeysIterator

An iterator over the set of assigned keys.

private class
LongObjectHashMap.ValuesContainer

A view over the set of values of this map.

private class
LongObjectHashMap.ValuesIterator

An iterator over the set of assigned values.

Field Summary

Modifier and TypeField and Description
protected int
assigned

The number of stored keys (assigned key slots), excluding the special "empty" key, if any (use size() instead).

protected boolean
hasEmptyKey

Special treatment for the "empty slot" key marker.

protected int
iterationSeed

Seed used to ensure the hash iteration order is different from an iteration to another.

public long[]
keys

The array holding keys.

protected double
loadFactor

The load factor for keys.

protected int
mask

Mask for slot scans in keys.

protected int
resizeAt

Expand (rehash) keys when assigned hits this value.

public Object[]
values

The array holding values.

Constructor Summary

AccessConstructor and Description
public
LongObjectHashMap()

New instance with sane defaults.

public
LongObjectHashMap(int
The expected number of elements guaranteed not to cause buffer expansion (inclusive).
expectedElements
)

New instance with sane defaults.

public
LongObjectHashMap(int
The expected number of elements guaranteed not to cause a rehash (inclusive).
expectedElements
,
double
The load factor for internal buffers. Insane load factors (zero, full capacity) are rejected by verifyLoadFactor(double).
loadFactor
)

New instance with the provided defaults.

public
LongObjectHashMap(LongObjectAssociativeContainer<? extends VType> container)

Create a hash map from all key-value pairs of another container.

Method Summary

Modifier and TypeMethod and Description
protected void
allocateBuffers(int arraySize)

Allocate new internal buffers.

protected void
allocateThenInsertThenRehash(int slot, long pendingKey, VType pendingValue)

This method is invoked when there is a new key/ value pair to be inserted into the buffers but there is not enough empty slots to do so.

public void
clear()

Implements com.carrotsearch.hppc.LongObjectMap.clear.

Clear all keys and values in the container.

public LongObjectHashMap<VType>
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean
containsKey(long key)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.containsKey.

Returns true if this container has an association to a value for the given key.

public void
ensureCapacity(int
The total number of keys, inclusive.
expectedElements
)

Implements com.carrotsearch.hppc.Preallocable.ensureCapacity.

Ensure this container can hold at least the given number of keys (entries) without resizing its buffers.

protected boolean
equalElements(LongObjectHashMap<?> other)

Return true if all keys of some other container exist in this container.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Implements com.carrotsearch.hppc.LongObjectMap.equals.

Compares the specified object with this set for equality.

public <T extends LongObjectProcedure<? super VType>> T
forEach(T procedure)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.forEach, com.carrotsearch.hppc.LongObjectAssociativeContainer.forEach.

Applies a given procedure to all keys-value pairs in this container.

public <T extends LongObjectPredicate<? super VType>> T
forEach(T predicate)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.forEach, com.carrotsearch.hppc.LongObjectAssociativeContainer.forEach.

Applies a given procedure to all keys-value pairs in this container.

public static <VType> LongObjectHashMap<VType>
from(long[] keys, VType[] values)

Creates a hash map from two index-aligned arrays of key-value pairs.

public VType
public VType
getOrDefault(long key, VType defaultValue)

Implements com.carrotsearch.hppc.LongObjectMap.getOrDefault.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.carrotsearch.hppc.LongObjectMap.hashCode.

Returns a hash code value for this object.

protected int
hashKey(long key)

Returns a hash code for the given key.

public boolean
indexExists(int
The index of a given key, as returned from indexOf.
index
)

Implements com.carrotsearch.hppc.LongObjectMap.indexExists.

public VType
indexGet(int
The index of an existing key.
index
)

Implements com.carrotsearch.hppc.LongObjectMap.indexGet.

Returns the value associated with an existing key.

public void
indexInsert(int
The index of a previously non-existing key, as returned from indexOf.
index
,
long key, VType value)

Implements com.carrotsearch.hppc.LongObjectMap.indexInsert.

Inserts a key-value pair for a key that is not present in the map.

public int
indexOf(long
The key to locate in the map.
key
)

Implements com.carrotsearch.hppc.LongObjectMap.indexOf.

Returns a logical "index" of a given key that can be used to speed up follow-up value setters or getters in certain scenarios (conditional logic).

public VType
indexRemove(int
The index of the key to remove, as returned from indexOf.
index
)

Implements com.carrotsearch.hppc.LongObjectMap.indexRemove.

Removes a key-value pair at an index previously acquired from indexOf.

public VType
indexReplace(int
The index of an existing key.
index
,
VType newValue)

Implements com.carrotsearch.hppc.LongObjectMap.indexReplace.

Replaces the value associated with an existing key and returns any previous value stored for that key.

public boolean
public Iterator<LongObjectCursor<VType>>
iterator()

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.iterator.

Returns a cursor over the entries (key-value pairs) in this map.

public LongObjectHashMap<VType>.KeysContainer
keys()

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.keys.

Returns a specialized view of the keys of this associated container.

protected int
nextIterationSeed()

Provides the next iteration seed used to build the iteration starting slot and offset increment.

public VType
put(long key, VType value)

Implements com.carrotsearch.hppc.LongObjectMap.put.

Place a given key and value in the container.

public int
putAll(LongObjectAssociativeContainer<? extends VType> container)

Implements com.carrotsearch.hppc.LongObjectMap.putAll.

Puts all keys from another container to this map, replacing the values of existing keys, if such keys are present.

public int
putAll(Iterable<? extends LongObjectCursor<? extends VType>> iterable)

Implements com.carrotsearch.hppc.LongObjectMap.putAll.

Puts all key/value pairs from a given iterable into this map.

public long
public long
ramBytesUsed()

Implements com.carrotsearch.hppc.Accountable.ramBytesUsed.

Bytes that is actually been used

protected void
rehash(long[] fromKeys, VType[] fromValues)

Rehash from old buffers to new buffers.

public void
release()

Implements com.carrotsearch.hppc.LongObjectMap.release.

Removes all elements from the collection and additionally releases any internal buffers.

public VType
remove(long key)

Implements com.carrotsearch.hppc.LongObjectMap.remove.

Remove all values at the given key.

public int
removeAll(LongContainer other)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.removeAll.

Removes all keys (and associated values) present in a given container.

public int
removeAll(LongObjectPredicate<? super VType> predicate)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.removeAll.

Removes all keys (and associated values) for which the predicate returns true.

public int
removeAll(LongPredicate predicate)

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.removeAll.

Removes all keys (and associated values) for which the predicate returns true.

protected void
shiftConflictingKeys(int gapSlot)

Shift all the slot-conflicting keys and values allocated to (and including) slot.

public int
public String
toString()

Overrides java.lang.Object.toString.

Convert the contents of this map to a human-friendly string.

public ObjectCollection<VType>

Returns:

Returns a container with all values stored in this map.
values
()

Implements com.carrotsearch.hppc.LongObjectAssociativeContainer.values.

Returns a container view of all values present in this container.

protected double
verifyLoadFactor(double loadFactor)

Validate load factor range and return it.

public String
visualizeKeyDistribution(int
The number of characters to "squeeze" the entire buffer into.
characters
)

Implements com.carrotsearch.hppc.LongObjectMap.visualizeKeyDistribution.

Visually depict the distribution of keys.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait