frost.collections

Class HashMap<K:HashKey<K>, V>

    └ Object

Implemented Interfaces:

Standard implementation of the Map interface, which associates keys with values. An arbitrary number of values can be stored in a HashMap and then retrieved in constant average time:

def alignment := HashMap<String, String>()
alignment["faerie"] := "good"
alignment["orc"]    := "evil"
alignment["golem"]  := "neutral"
Console.printLine(alignment["faerie"])

This will display the value "good".

Source Code:
View Source

Initializer Summary

init()
Creates a new, empty HashMap.
init(map:MapView<K, V>)
init(entries:CollectionView<(frost.collections.HashMap.K, frost.collections.HashMap.V)>)
Inherited Fields:

Instance Method Summary

-- index operator --
[](key:K):V?
Returns the value mapped to the given key, or null if no such mapping exists.
contains(key:K):Bit
Returns true if the map contains the given key (even if the value it maps to is null)
-- indexed assignment operator --
[]:=(key:K, value:V)
Inserts a new value or replaces an existing value.
remove(key:K)
Removes the entry for key, if present.
clear()
Removes all entries from the list.
filterInPlace(test:(K, V)=>(Bit))
Removes all entries from the map for which test returns false.

Initializers

init ()

Creates a new, empty HashMap.

init (map:MapView<K, V>)
Parameters:
map - value of type MapView<K, V>

Instance Methods

-- index operator --
@override
function [] (key:K
):V?

Returns the value mapped to the given key, or null if no such mapping exists. If the map's type permits null values, this function does not distinguish between cases where the map does not contain the given key, and cases where it does contain the key, but it maps to null. The contains method can be used to disambiguate this situation.

Parameters:
key - value of type K
Overrides:
frost.collections.MapView.[]
@override
function contains (key:K
):Bit

Returns true if the map contains the given key (even if the value it maps to is null)

Parameters:
key - value of type K
Overrides:
frost.collections.MapView.contains
-- indexed assignment operator --
@override
method []:= (key:K,
 value:V)

Inserts a new value or replaces an existing value.

Parameters:
key - value of type K
value - value of type V
Overrides:
frost.collections.MapWriter.[]:=
@override
method remove (key:K)

Removes the entry for key, if present.

Parameters:
key - value of type K
Overrides:
frost.collections.MapWriter.remove
@override
method clear ()

Removes all entries from the list.

Overrides:
frost.collections.MapWriter.clear
@override
method filterInPlace (test:(K, V)=>(Bit))

Removes all entries from the map for which test returns false.

Parameters:
test - value of type (K, V)=>(Bit)
Overrides:
frost.collections.MapWriter.filterInPlace