Top Description Methods
com.carrotsearch.hppc

public Interface ObjectIntMap<KType>

extends ObjectIntAssociativeContainer<KType>
Known Direct Implementers
com.carrotsearch.hppc.SortedIterationObjectIntHashMap, com.carrotsearch.hppc.ObjectIntHashMap
Annotations
@Generated:KTypeVTypeMap.java
date:2024-06-04T15:20:17+0200
Imports
com.carrotsearch.hppc.cursors.ObjectIntCursor

An associative container with unique binding from keys to a single value.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

Returns the current value associated with key (after changes).
addTo
(KType
The key of the value to adjust.
key
,
int
The value to put or add to the existing value if key exists.
additionValue
)

An equivalent of calling

putOrAdd(key, additionValue, additionValue);
public void
clear()

Clear all keys and values in the container.

public boolean
equals(Object obj)

Compares the specified object with this set for equality.

public int

Returns:

Returns the value associated with the given key or the default value for the value type, if the key is not associated with any value. For numeric value types, this default value is 0, for object types it is null.
get
(KType key)

public int

Returns:

Returns the value associated with the given key or the provided default value if the key is not associated with any value.
getOrDefault
(KType key, int defaultValue)

public int

Returns:

A hash code of elements stored in the map. The hash code is defined as a sum of hash codes of keys and values stored within the set). Because sum is commutative, this ensures that different order of elements in a set does not affect the hash code.
hashCode
()

public boolean

Returns:

Returns true if the index corresponds to an existing key or false otherwise. This is equivalent to checking whether the index is a positive value (existing keys) or a negative value (non-existing keys).
indexExists
(int
The index of a given key, as returned from indexOf.
index
)

public int

Returns:

Returns the value currently associated with the key.
indexGet
(int
The index of an existing key.
index
)

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
,
KType key, int value)

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

public int

Returns:

A non-negative value of the logical "index" of the key in the map or a negative value if the key did not exist.
indexOf
(KType
The key to locate in the map.
key
)

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 int

Returns:

Returns the previous value associated with the key.
indexRemove
(int
The index of the key to remove, as returned from indexOf.
index
)

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

public int

Returns:

Returns the previous value associated with the key.
indexReplace
(int
The index of an existing key.
index
,
int newValue)

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

public int

Returns:

The value previously stored under the given key in the map is returned.
put
(KType key, int value)

Place a given key and value in the container.

public int

Returns:

Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.
putAll
(ObjectIntAssociativeContainer<? extends KType> container)

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

public int

Returns:

Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.
putAll
(Iterable<? extends ObjectIntCursor<? extends KType>> iterable)

Puts all keys from an iterable cursor to this map, replacing the values of existing keys, if such keys are present.

public default boolean

Returns:

true if key did not exist and value was placed in the map, false otherwise.
putIfAbsent
(KType key, int value)

If the specified key is not already associated with a value, associates it with the given value.

public int

Returns:

Returns the current value associated with key (after changes).
putOrAdd
(KType
The key of the value to adjust.
key
,
int
The value to put if key does not exist.
putValue
,
int
The value to add to the existing value if key exists.
incrementValue
)

If key exists, putValue is inserted into the map, otherwise any existing value is incremented by additionValue.

public void
release()

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

public int
remove(KType key)

Remove all values at the given key.

public String

Returns:

Returns a sequence of characters where '.' depicts an empty fragment of the internal buffer and 'X' depicts full or nearly full capacity within the buffer's range and anything between 1 and 9 is between.
visualizeKeyDistribution
(int
The number of characters to "squeeze" the entire buffer into.
characters
)

Visually depict the distribution of keys.

Inherited from com.carrotsearch.hppc.ObjectIntAssociativeContainer:
containsKeyforEachforEachisEmptyiteratorkeysremoveAllremoveAllremoveAllsizevalues

Method Detail

addToback to summary
public int addTo(KType key, int additionValue)

An equivalent of calling

putOrAdd(key, additionValue, additionValue);
Parameters
key:KType

The key of the value to adjust.

additionValue:int

The value to put or add to the existing value if key exists.

Returns:int

Returns the current value associated with key (after changes).

clearback to summary
public void clear()

Clear all keys and values in the container.

See Also
release()
equalsback to summary
public boolean equals(Object obj)

Compares the specified object with this set for equality. Returns true if and only if the specified object is also a ObjectIntMap and both objects contains exactly the same key-value pairs.

getback to summary
public int get(KType key)
Returns:int

Returns the value associated with the given key or the default value for the value type, if the key is not associated with any value. For numeric value types, this default value is 0, for object types it is null.

getOrDefaultback to summary
public int getOrDefault(KType key, int defaultValue)
Returns:int

Returns the value associated with the given key or the provided default value if the key is not associated with any value.

hashCodeback to summary
public int hashCode()
Returns:int

A hash code of elements stored in the map. The hash code is defined as a sum of hash codes of keys and values stored within the set). Because sum is commutative, this ensures that different order of elements in a set does not affect the hash code.

indexExistsback to summary
public boolean indexExists(int index)
Parameters
index:int

The index of a given key, as returned from indexOf.

Returns:boolean

Returns true if the index corresponds to an existing key or false otherwise. This is equivalent to checking whether the index is a positive value (existing keys) or a negative value (non-existing keys).

See Also
indexOf
indexGetback to summary
public int indexGet(int index)

Returns the value associated with an existing key.

Parameters
index:int

The index of an existing key.

Returns:int

Returns the value currently associated with the key.

Exceptions
AssertionError:
If assertions are enabled and the index does not correspond to an existing key.
See Also
indexOf
indexInsertback to summary
public void indexInsert(int index, KType key, int value)

Inserts a key-value pair for a key that is not present in the map. This method may help in avoiding double recalculation of the key's hash.

Parameters
index:int

The index of a previously non-existing key, as returned from indexOf.

Exceptions
AssertionError:
If assertions are enabled and the index corresponds to an existing key.
See Also
indexOf
indexOfback to summary
public int indexOf(KType key)

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).

The semantics of "indexes" are not strictly defined. Indexes may (and typically won't be) contiguous.

The index is valid only between map modifications (it will not be affected by read-only operations like iteration or value retrievals).

Parameters
key:KType

The key to locate in the map.

Returns:int

A non-negative value of the logical "index" of the key in the map or a negative value if the key did not exist.

See Also
indexExists, indexGet, indexInsert, indexReplace
indexRemoveback to summary
public int indexRemove(int index)

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

Parameters
index:int

The index of the key to remove, as returned from indexOf.

Returns:int

Returns the previous value associated with the key.

Exceptions
AssertionError:
If assertions are enabled and the index does not correspond to an existing key.
See Also
indexOf
indexReplaceback to summary
public int indexReplace(int index, int newValue)

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

Parameters
index:int

The index of an existing key.

Returns:int

Returns the previous value associated with the key.

Exceptions
AssertionError:
If assertions are enabled and the index does not correspond to an existing key.
See Also
indexOf
putback to summary
public int put(KType key, int value)

Place a given key and value in the container.

Returns:int

The value previously stored under the given key in the map is returned.

putAllback to summary
public int putAll(ObjectIntAssociativeContainer<? extends KType> container)

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

Returns:int

Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.

putAllback to summary
public int putAll(Iterable<? extends ObjectIntCursor<? extends KType>> iterable)

Puts all keys from an iterable cursor to this map, replacing the values of existing keys, if such keys are present.

Returns:int

Returns the number of keys added to the map as a result of this call (not previously present in the map). Values of existing keys are overwritten.

putIfAbsentback to summary
public default boolean putIfAbsent(KType key, int value)

If the specified key is not already associated with a value, associates it with the given value.

Returns:boolean

true if key did not exist and value was placed in the map, false otherwise.

putOrAddback to summary
public int putOrAdd(KType key, int putValue, int incrementValue)

If key exists, putValue is inserted into the map, otherwise any existing value is incremented by additionValue.

Parameters
key:KType

The key of the value to adjust.

putValue:int

The value to put if key does not exist.

incrementValue:int

The value to add to the existing value if key exists.

Returns:int

Returns the current value associated with key (after changes).

releaseback to summary
public void release()

Removes all elements from the collection and additionally releases any internal buffers. Typically, if the object is to be reused, a simple clear() should be a better alternative since it'll avoid reallocation.

See Also
clear()
removeback to summary
public int remove(KType key)

Remove all values at the given key. The default value for the key type is returned if the value does not exist in the map.

visualizeKeyDistributionback to summary
public String visualizeKeyDistribution(int characters)

Visually depict the distribution of keys.

Parameters
characters:int

The number of characters to "squeeze" the entire buffer into.

Returns:String

Returns a sequence of characters where '.' depicts an empty fragment of the internal buffer and 'X' depicts full or nearly full capacity within the buffer's range and anything between 1 and 9 is between.