HashMap

cats.collections.HashMap
See theHashMap companion object
final class HashMap[K, +V]

An immutable hash map using cats.kernel.Hash for hashing.

Implemented using the CHAMP encoding.

Type parameters

K

the type of the keys contained in this hash map.

V

the type of the values contained in this hash map.

Value parameters

hashKey

the cats.kernel.Hash instance used for hashing keys.

Attributes

See also
Companion
object
Source
HashMap.scala
Graph
Supertypes
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

final def ===[VV >: V](that: HashMap[K, VV])(implicit eqValue: Eq[VV]): Boolean

Typesafe equality operator.

Typesafe equality operator.

This method is similar to scala.Any#== except that it only allows two cats.data.HashMap values of the same key-value type to be compared to each other, and uses equality provided by cats.kernel.Eq instances, rather than using the universal equality provided by java.lang.Object#equals.

Value parameters

eqValue

the cats.kernel.Eq instance to use for comparing values.

that

the cats.data.HashMap to check for equality with this map.

Attributes

Returns

true if this map and that are equal, false otherwise.

Source
HashMap.scala
final def contains(key: K): Boolean

Test whether the map contains key.

Test whether the map contains key.

Value parameters

key

the key to check for map membership.

Attributes

Returns

true if the map contains key, false otherwise.

Source
HashMap.scala
final override def equals(that: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

- It is reflexive: for any instance x of type Any, x.equals(x) should return true. - It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true. - It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
Source
HashMap.scala
final def foreach[U](f: (K, V) => U): Unit

Apply f to each key-value pair for its side effects.

Apply f to each key-value pair for its side effects.

Value parameters

f

the function to apply to each key-value pair.

Attributes

Source
HashMap.scala
final def get(key: K): Option[V]

Get the value associated with key in this map.

Get the value associated with key in this map.

Value parameters

key

the key to check for map membership.

Attributes

Returns

A scala.Some containing the value if present, else scala.None.

Source
HashMap.scala
final def getOrElse[VV >: V](key: K, default: => VV): VV

Get the value associated with key in this map, or default if not present.

Get the value associated with key in this map, or default if not present.

Value parameters

default

the value to use in case key is not present.

key

the key to check for map membership.

Attributes

Returns

the value if present, else default.

Source
HashMap.scala
final def hash[VV >: V](implicit hashValue: Hash[VV]): Int

Compute a hash code value for this map.

Compute a hash code value for this map.

This method is similar to java.lang.Object#hashCode except that it computes a hash code according to cats.Hash instances.

Value parameters

hashValue

the cats.kernel.Hash instance to use for hashing values of type VV.

Attributes

Returns

a hash code value for this map.

Source
HashMap.scala
final override def hashCode(): Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
Source
HashMap.scala
final def isEmpty: Boolean

Tests whether the map is empty.

Tests whether the map is empty.

Attributes

Returns

true if the map contains no elements, false otherwise.

Source
HashMap.scala
final def iterator: Iterator[(K, V)]

An iterator for this map that can be used only once.

An iterator for this map that can be used only once.

Attributes

Returns

an iterator that iterates through the key-value pairs of this map.

Source
HashMap.scala
final def keysIterator: Iterator[K]

An iterator for the keys of this map that can be used only once.

An iterator for the keys of this map that can be used only once.

Attributes

Returns

an iterator that iterates through the keys of this map.

Source
HashMap.scala
final def nonEmpty: Boolean

Tests whether the map is not empty.

Tests whether the map is not empty.

Attributes

Returns

true if the map contains at least one element, false otherwise.

Source
HashMap.scala
final def removed(key: K): HashMap[K, V]

Creates a new map with the given key removed from the map.

Creates a new map with the given key removed from the map.

Value parameters

key

the key to be removed.

Attributes

Returns

a new map that contains all elements of this map but that does not contain key.

Source
HashMap.scala
final def show[VV >: V](implicit showKey: Show[K], showValue: Show[VV]): String

Typesafe stringification operator.

Typesafe stringification operator.

This method is similar to java.lang.Object#toString except that it stringifies values according to cats.Show instances.

Value parameters

showKey

the cats.Show instance to use for showing keys of type K.

showValue

the cats.Show instance to use for showing values of type V.

Attributes

Returns

a java.lang.String representation of this map.

Source
HashMap.scala
final def size: Int

The size of this map.

The size of this map.

Attributes

Returns

the number of elements in this map.

Source
HashMap.scala
final def toMap: Map[K, V]

Attributes

Source
HashMap.scala
final override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
HashMap.scala
final def updated[VV >: V](key: K, value: VV): HashMap[K, VV]

Creates a new map with an additional key-value pair, unless the key is already present, in which case the value for key is replaced by value.

Creates a new map with an additional key-value pair, unless the key is already present, in which case the value for key is replaced by value.

Value parameters

key

the key to be added.

value

the value to be added.

Attributes

Returns

a new map that contains all key-value pairs of this map and that also contains a mapping from key to value.

Source
HashMap.scala
final def valuesIterator: Iterator[V]

An iterator for the values of this map that can be used only once.

An iterator for the values of this map that can be used only once.

Attributes

Returns

an iterator that iterates through the values of this map.

Source
HashMap.scala

Inherited methods

final def concat[VV >: V](iterable: IterableOnce[(K, VV)]): HashMap[K, VV]

Creates a new map with all key-value pairs of this map, and all key-value pairs of iterable.

Creates a new map with all key-value pairs of this map, and all key-value pairs of iterable.

Value parameters

iterable

the collection of key-value pairs to be added.

Attributes

Returns

a new map that contains all key-value pairs of this map and iterable.

Inherited from:
HashMapCompat (hidden)
Source
HashMapCompat.scala
override def knownSize: Int

Attributes

Definition Classes
HashMapCompat -> IterableOnce
Inherited from:
HashMapCompat (hidden)
Source
HashMapCompat.scala
def stepper[S <: Stepper[_]](implicit shape: StepperShape[(K, V), S]): S

Attributes

Inherited from:
IterableOnce

Implicits

Implicits

implicit val hashKey: Hash[K]

Attributes

Source
HashMap.scala