scala.collection.mutable

class OpenHashMap

[source: scala/collection/mutable/OpenHashMap.scala]

class OpenHashMap[Key, Value](initialSize : Int)
extends Map[Key, Value]
A mutable hash map based on an open hashing scheme. The precise scheme is undefined, but it should make a reasonable effort to ensure that an insert with consecutive hash codes is not unneccessarily penalised. In particular, mappings of consecutive integer keys should work without significant performance loss.
Author
David MacIver
Additional Constructor Summary
def this : OpenHashMap[Key, Value]
Method Summary
def -= (key : Key) : Unit
Remove a key from this map, noop if key is not present.
override def clone : OpenHashMap[Key, Value]
Return a clone of this map.
def elements : Iterator[(Key, Value)]
An iterator over the elements of this map. Use of this iterator follows the same contract for concurrent modification as the foreach method.
override def foreach (f : ((Key, Value)) => Unit) : Unit
Loop over the key, value mappings of this map. The behaviour of modifying the map during an iteration is as follows:
  • Deleting a mapping is always permitted.
  • Changing the value of mapping which is already present is permitted.
  • Anything else is not permitted. It will usually, but not always, throw an exception.
def get (key : Key) : Option[Value]
Check if this map maps key to a value and return the value if it exists.
protected def hashOf (key : Key) : Int
override def retain (f : (Key, Value) => Boolean) : Unit
This method retains only those mappings for which the predicate p returns true.
def size : Int
Compute the number of key-to-value mappings.
override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.
override def transform (f : (Key, Value) => Value) : Unit
This function transforms all the values of mappings contained in this map with function f.
def update (key : Key, value : Value) : Unit
This method allows one to add a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden by this function.
Methods inherited from Map
+=, +=, ++=, ++=, +, +, ++, ++, -=, --=, --=, -, removeKey, put, -, --, --, clear, getOrElseUpdate, <<, readOnly, +=, incl, excl
Methods inherited from Map
getOrElse, isEmpty, apply, contains, isDefinedAt, keys, keySet, values, equals, hashCode, toString, default, projection, filterKeys, mapElements
Methods inherited from Collection
toArray
Methods inherited from Iterable
concat, ++, map, flatMap, filter, partition, takeWhile, dropWhile, take, drop, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toSeq, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Additional Constructor Details
def this : OpenHashMap[Key, Value]

Method Details
def size : Int
Compute the number of key-to-value mappings.
Returns
the number of mappings

protected def hashOf(key : Key) : Int

def update(key : Key, value : Value) : Unit
This method allows one to add a new mapping from key to value to the map. If the map already contains a mapping for key, it will be overridden by this function.
Parameters
key - The key to update
value - The new value
Overrides
Map.update

def -=(key : Key) : Unit
Remove a key from this map, noop if key is not present.
Parameters
key - the key to be removed
Overrides
Map.-=

def get(key : Key) : Option[Value]
Check if this map maps key to a value and return the value if it exists.
Parameters
key - the key of the mapping of interest
Returns
the value of the mapping, if it exists

def elements : Iterator[(Key, Value)]
An iterator over the elements of this map. Use of this iterator follows the same contract for concurrent modification as the foreach method.

override def clone : OpenHashMap[Key, Value]
Return a clone of this map.
Returns
a map with the same elements.
Overrides
Map.clone

override def foreach(f : ((Key, Value)) => Unit) : Unit
Loop over the key, value mappings of this map. The behaviour of modifying the map during an iteration is as follows:
  • Deleting a mapping is always permitted.
  • Changing the value of mapping which is already present is permitted.
  • Anything else is not permitted. It will usually, but not always, throw an exception.
Parameters
f - The function to apply to each key, value mapping.

override def transform(f : (Key, Value) => Value) : Unit
This function transforms all the values of mappings contained in this map with function f.
Parameters
f - The transformation to apply
Overrides
Map.transform

override def retain(f : (Key, Value) => Boolean) : Unit
This method retains only those mappings for which the predicate p returns true.
Parameters
p - The test predicate
Deprecated
cannot be type inferred because if retain in Iterable.
Overrides
Map.retain

override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.