MHashMap<K, V> class
final
A mutable hash map backed by a linked-chain hash table.
Amortized O(1) get, put, and remove. The table rehashes when the load factor threshold is exceeded. Default capacity is 16 with a 0.75 load factor. Construct with MHashMap.empty or directly via the default constructor.
- Mixed-in types
-
- RIterableOnce<
(K, V)> - RIterable<
(K, V)> - RMap<
K, V> - MMap<
K, V>
- RIterableOnce<
- Available extensions
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- head → (K, V)
-
Returns the first element of this collection, or throws if it is empty.
no setterinherited
-
headOption
→ Option<
(K, V)> -
Returns the first element of this collection as a Some if non-empty.
If this collction is empty, None is returned.
no setterinherited
-
init
→ MMap<
K, V> -
Returns all elements from this collection except the last. If this
collection is empty, an empty collection is returned.
no setterinherited
- initialCapacity → int
-
final
-
inits
→ RIterator<
MMap< K, V> > -
Returns an iterator of all potential tails of this collection, starting
with the entire collection and ending with an empty one.
no setterinherited
- isEmpty → bool
-
Whether this collection contains no elements.
no setteroverride
- isNotEmpty → bool
-
Whether this collection contains at least one element.
no setterinherited
- isTraversableAgain → bool
-
Whether this collection can be traversed more than once.
no setterinherited
-
iterator
→ RIterator<
(K, V)> -
Returns an RIterator over the elements of this collection.
no setteroverride
-
keys
→ ISet<
K> -
Returns a RIterable of all the keys stored in the map.
no setteroverride
-
keySet
→ RSet<
K> -
Returns an RSet of all keys in this map.
no setterinherited
-
keysIterator
→ RIterator<
K> -
Returns an RIterator over all keys of this map.
no setterinherited
- knownSize → int
-
Returns the number of elements in this collection, if that number is
already known. If not, -1 is returned.
no setteroverride
- last → (K, V)
-
Returns the last element of this collection, or throws if it is empty.
no setterinherited
-
lastOption
→ Option<
(K, V)> -
Returns the last element of this collection as a Some, or None if this
collection is empty.
no setterinherited
- loadFactor → double
-
final
- nonEmpty → bool
-
Whether this collection contains at least one element.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Returns the number of elements in this collection.
no setteroverride
-
tail
→ MMap<
K, V> -
Returns a new collection with the first element removed. If this
collection is empty, an empty collection is returned.
no setterinherited
-
tails
→ RIterator<
MMap< K, V> > -
Returns an iterator of all potential tails of this collection, starting
with the entire collection and ending with an empty one.
no setterinherited
-
values
→ RIterable<
V> -
Returns a RIterable of all values stored in this map.
no setterinherited
-
valuesIterator
→ RIterator<
V> -
Returns a RIterator of all values stored in this map.
no setteroverride
Methods
-
clear(
) → void -
Removes all entries from this map.
override
-
collect<
B> (Function1< (K, V), Option< f) → RIterable<B> >B> -
Returns a new collection by applying
fto each element an only keeping results of type Some.inherited -
collectFirst<
B> (Function1< (K, V), Option< f) → Option<B> >B> -
Applies
fto each element of this collection, returning the first element that results in a Some, if any.inherited -
concat(
covariant RIterableOnce< (K, V)> suffix) → MHashMap<K, V> -
Returns a copy of this collection, with
elemsadded to the end.override -
contains(
K key) → bool -
Returns true if this map contains the key
key, false otherwise.override -
copyToArray(
Array< (K, V)> xs, [int start = 0, int? n]) → int -
Copies elements into
xsstarting atstart, writing at mostnelements (or all remaining capacity whennis omitted).inherited -
corresponds<
B> (covariant RIterable< B> that, Function2<(K, V), B, bool> p) → bool -
Returns true if this collection has the same size as
thatand each corresponding element from this andthatsatisfies the given predicatep.inherited -
count(
Function1< (K, V), bool> p) → int -
Return the number of elements in this collection that satisfy the given
predicate.
inherited
-
defaultValue(
K key) → V -
Called by operator [] when
keyis absent. Throws by default; override to supply a fallback value.inherited -
drop(
int n) → MMap< K, V> -
Returns a new collection with the first
nelements removed.inherited -
dropRight(
int n) → MMap< K, V> -
Return a new collection with the last
nelements removed.inherited -
dropWhile(
Function1< (K, V), bool> p) → MMap<K, V> -
Returns a new collection with leading elements satisfying
premoved.inherited -
exists(
Function1< (K, V), bool> p) → bool -
Returns true if any element of this collection satisfies the given
predicate, false if no elements satisfy it.
inherited
-
filter(
Function1< (K, V), bool> p) → MMap<K, V> -
Returns a new collection containing only elements that satisfy
p.inherited -
filterInPlace(
Function1< (K, V), bool> p) → MMap<K, V> -
Removes all entries that do not satisfy
pin place and returnsthis.inherited -
filterNot(
Function1< (K, V), bool> p) → MMap<K, V> -
Returns a new collection containing only elements that do not
satisfy
p.inherited -
find(
Function1< (K, V), bool> p) → Option<(K, V)> -
Returns the first element from this collection that satisfies the given
predicate
p. If no element satisfiesp, None is returned.inherited -
flatMap<
B> (covariant Function1< (K, V), RIterableOnce< f) → RIterable<B> >B> -
Returns a new collection by applying
fto each element and concatenating the results.inherited -
fold(
(K, V) init, Function2< (K, V), (K, V), (K, V)> op) → (K, V) -
Alias for foldLeft with a same-type accumulator.
inherited
-
foldLeft<
B> (B z, Function2< B, (K, V), B> op) → B -
Returns a summary value by applying
opto all elements of this collection, moving from left to right. The fold uses a seed value ofz.inherited -
foldRight<
B> (B z, Function2< (K, V), B, B> op) → B -
Returns a summary value by applying
opto all elements of this collection, moving from right to left. The fold uses a seed value ofz.inherited -
forall(
Function1< (K, V), bool> p) → bool -
Returns true if all elements of this collection satisfy the given
predicate, false if any elements do not.
inherited
-
foreach<
U> (Function1< (K, V), U> f) → void -
Applies
fto each element of this collection, discarding any resulting values.inherited -
get(
K key) → Option< V> -
Returns the value for the given key
keyas a Some, or None if this map doesn't contain the key.override -
getOrElse(
K key, Function0< V> orElse) → V -
Returns the value for the given key
key, ororElseif this map doesn't contain the key.inherited -
getOrElseUpdate(
K key, Function0< V> defaultValue) → V -
Returns the value for
key, or inserts and returnsdefaultValuewhen the key is absent.override -
groupBy<
K2> (Function1< (K, V), K2> f) → IMap<K2, MMap< K, V> > -
Partitions all elements of this collection by applying
fto each element and accumulating duplicate keys in the returned IMap.inherited -
grouped(
int size) → RIterator< MMap< K, V> > -
Returns a new iterator where each element is a collection of
sizeelements from the original collection. The last element may contain less thansizeelements.inherited -
groupMap<
K, B> (Function1< (K, V), K> key, Function1<(K, V), B> f) → IMap<K, RIterable< B> > -
Creates a new map by generating a key-value pair for each elements of this
collection using
keyandf. Any elements that generate the same key will have the resulting values accumulated in the returned map.inherited -
groupMapReduce<
K, B> (Function1< (K, V), K> key, Function1<(K, V), B> f, Function2<B, B, B> reduce) → IMap<K, B> -
Partitions all elements of this collection by applying
keyto each element. Additionallyfis applied to each element to generate a value. If multiple values are generating for the same key, those values will be combined usingreduce.inherited -
map<
B> (Function1< (K, V), B> f) → RIterable<B> -
Returns a new collection by applying
fto each element.inherited -
maxByOption<
B> (Function1< (K, V), B> f, Order<B> order) → Option<(K, V)> -
Finds the largest element in this collection by applying
fto each element and using the given Order to find the greatest.inherited -
maxOption(
Order< (K, V)> order) → Option<(K, V)> -
Finds the largest element in this collection according to the given
Order.
inherited
-
minByOption<
B> (Function1< (K, V), B> f, Order<B> order) → Option<(K, V)> -
Finds the smallest element in this collection by applying
fto each element and using the given Order to find the greatest.inherited -
minOption(
Order< (K, V)> order) → Option<(K, V)> -
Finds the largest element in this collection according to the given
Order.
inherited
-
mkString(
{String? start, String? sep, String? end}) → String -
Returns a String by using each elements toString(), adding
sepbetween each element. Ifstartis defined, it will be prepended to the resulting string. Ifendis defined, it will be appended to the resulting string.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
partition(
Function1< (K, V), bool> p) → (MMap<K, V> , MMap<K, V> ) -
Returns 2 collections as a tuple where the first tuple element will be a
collection of elements that satisfy the given predicate
p. The second item of the returned tuple will be elements that do not satisfyp.inherited -
partitionMap<
A1, A2> (Function1< (K, V), Either< f) → (RIterable<A1, A2> >A1> , RIterable<A2> ) -
Applies
fto each element of this collection and returns a separate collection for all applications resulting in a Left and Right respectively.inherited -
put(
K key, V value) → Option< V> -
Associates
keywithvalue, returning the previous value asSome, orNoneifkeywas not present.override -
reduce(
Function2< (K, V), (K, V), (K, V)> op) → (K, V) -
Reduces this collection to a single value by applying
opleft to right.inherited -
reduceLeft(
Function2< (K, V), (K, V), (K, V)> op) → (K, V) -
Reduces from left to right. Throws if empty.
inherited
-
reduceLeftOption(
Function2< (K, V), (K, V), (K, V)> op) → Option<(K, V)> -
Returns a summary values of all elements of this collection by applying
fto each element, moving left to right.inherited -
reduceOption(
Function2< (K, V), (K, V), (K, V)> op) → Option<(K, V)> -
Returns a summary values of all elements of this collection by applying
fto each element, moving left to right.inherited -
reduceRight(
Function2< (K, V), (K, V), (K, V)> op) → (K, V) -
Reduces from right to left. Throws if empty.
inherited
-
reduceRightOption(
Function2< (K, V), (K, V), (K, V)> op) → Option<(K, V)> -
Returns a summary values of all elements of this collection by applying
fto each element, moving right to left.inherited -
remove(
K key) → Option< V> -
Removes
keyand returns its value asSome, orNoneif absent.override -
removeAll(
RIterableOnce< K> key) → MMap<K, V> -
Removes all of the given
keys and returnsthis.inherited -
scan<
B> (B z, Function2< B, (K, V), B> op) → RIterableOnce<B> -
Alias for scanLeft.
inherited
-
scanLeft<
B> (B z, Function2< B, (K, V), B> op) → RIterable<B> -
Returns a new collection of running totals starting with
z.inherited -
scanRight<
B> (B z, Function2< (K, V), B, B> op) → RIterable<B> -
Returns a new collection of running totals starting with
z, traversing from right to left.inherited -
slice(
int from, int until) → MMap< K, V> -
Returns a new collection containing elements in the range
[from, until).inherited -
sliding(
int size, [int step = 1]) → RIterator< MMap< K, V> > -
Returns an iterator where elements are fixed size chunks of size
nof the original collection. Each chunk is calculated by sliding a 'window' of sizenover the original collection, moving the windowstepelements at a time.inherited -
span(
Function1< (K, V), bool> p) → (MMap<K, V> , MMap<K, V> ) -
Returns two collections: elements before and starting from the first
element that does not satisfy
p.inherited -
splitAt(
int n) → (MMap< K, V> , MMap<K, V> ) -
Returns two collections: the first
nelements and the remainder.inherited -
take(
int n) → MMap< K, V> -
Returns a new collection containing only the first
nelements.inherited -
takeRight(
int n) → MMap< K, V> -
Returns a new collection with the last
nelements of this collection. Ifnis greater than the size of this collection, the original collection is returned.inherited -
takeWhile(
Function1< (K, V), bool> p) → MMap<K, V> -
Returns a new collection of leading elements that satisfy
p.inherited -
tapEach<
U> (Function1< (K, V), U> f) → MMap<K, V> -
Applies
fto each element in this collection, discarding any results and returns this collection.inherited -
toIList(
) → IList< (K, V)> -
Returns an IList with the same elements as this collection.
inherited
-
toIMap(
) → IMap< A, B> -
Available on RIterable<
Creates a new IMap where each tuple element of this list is used to create a key and value respectively.(A, B)> , provided by the RIterableTuple2Ops extension -
toIndexedSeq(
) → IndexedSeq< (K, V)> -
Returns an IndexedSeq with the same elements as this collection.
inherited
-
toISet(
) → ISet< (K, V)> -
Returns an ISet with the same elements as this collection, duplicates
removed.
inherited
-
toIVector(
) → IVector< (K, V)> -
Returns an IVector with the same elements as this collection.
inherited
-
toList(
{bool growable = true}) → List< (K, V)> -
Returns a new List with the same elements as this collection.
inherited
-
toMap(
) → Map< K, V> -
Returns a new Map containing the same key-value pairs.
inherited
-
toSeq(
) → RSeq< (K, V)> -
Returns a RSeq with the same elements as this collection.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unzip(
) → (RIterable< A> , RIterable<B> ) -
Available on RIterable<
Splits a collection of pairs into two separate collections.(A, B)> , provided by the RibsIterableTuple2Ops extension -
update(
K key, V value) → void -
Sets
keytovalue. Alias for put.inherited -
updateWith(
K key, Function1< Option< remappingFunction) → Option<V> , Option<V> >V> -
Computes a new value for
keyby applyingremappingFunctionto the current value (or None if absent).inherited -
withDefault(
Function1< K, V> f) → MMap<K, V> -
Returns a view of this map where key lookups fall back to
ffor missing keys.inherited -
withDefaultValue(
V value) → MMap< K, V> -
Returns a view of this map where key lookups return
valuefor missing keys.inherited -
zip<
B> (RIterableOnce< B> that) → RIterable<((K, V), B)> -
Returns a new collection that combines corresponding elements from this
collection and
thatas a tuple. The length of the returned collection will be the minimum of this collections size and the size ofthat.inherited -
zipAll<
B> (RIterableOnce< B> that, (K, V) thisElem, B thatElem) → RIterable<((K, V), B)> -
Returns a new collection that combines corresponding elements from this
collection and
thatas a tuple. The length of the returned collection will be the maximum of this collections size and thes size ofthat. If this collection is shorter thanthat,thisElemwill be used to fill in the resulting collection. Ifthatis shorter,thatElemwill be used to will in the resulting collection.inherited -
zipWithIndex(
) → RIterable< ((K, V), int)> -
Return a new collection with each element of this collection paired with
it's respective index.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
K key) → V -
Returns the value associated with the given
key, or the defaultValue of this map (which could potentially throw).inherited -
operator []=(
K key, V value) → void -
Sets the value for
keytovalue. Alias for update.inherited
Static Methods
Constants
- DefaultInitialCapacity → const int
- DefaultLoadFactor → const double