Class DefaultHashMap<K:HashKey<K>, V>
└
Object
Implemented Interfaces:
As HashMap, but additionally has a default value which is returned for keys which are not present
in the map.
- Source Code:
- View Source
Initializer Summary
init (default :)V init (entries :,CollectionView<(frost.collections.DefaultHashMap.K, frost.collections.DefaultHashMap.V)> default :)V
Inherited Fields:
Instance Method Summary
-- index operator --[] (key :):K V? - Returns the value mapped to the given key, or
nullif no such mapping exists. -- index operator --[] (key :):K V contains (key :):K Bit - Returns
trueif the map contains the given key (even if the value it maps to isnull) -- 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
testreturnsfalse.
Initializers
init
(entries :CollectionView<(frost.collections.DefaultHashMap.K, frost.collections.DefaultHashMap.V)> ,
default :V )
- Parameters:
-
- value of typeentries CollectionView<(frost.collections.DefaultHashMap.K, frost.collections.DefaultHashMap.V)>
- value of typedefault V
Instance Methods
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:
-
- value of typekey K
- Overrides:
- frost.collections.MapView.[]
Returns true if the map contains the given key (even if the value it maps to is null)
- Parameters:
-
- value of typekey K
- Overrides:
- frost.collections.MapView.contains
Inserts a new value or replaces an existing value.
- Overrides:
- frost.collections.MapWriter.[]:=
@override
method remove
(key :K )
Removes the entry for key, if present.
- Parameters:
-
- value of typekey 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:
-
- value of typetest (K, V)=>(Bit)
- Overrides:
- frost.collections.MapWriter.filterInPlace