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
Available extensions

Constructors

MHashMap({int initialCapacity = DefaultInitialCapacity, double loadFactor = DefaultLoadFactor})

Properties

hashCode int
The hash code for this object.
no setterinherited
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<B>> f) RIterable<B>
Returns a new collection by applying f to each element an only keeping results of type Some.
inherited
collectFirst<B>(Function1<(K, V), Option<B>> f) Option<B>
Applies f to 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 elems added 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 xs starting at start, writing at most n elements (or all remaining capacity when n is 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 that and each corresponding element from this and that satisfies the given predicate p.
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 key is absent. Throws by default; override to supply a fallback value.
inherited
drop(int n) MMap<K, V>
Returns a new collection with the first n elements removed.
inherited
dropRight(int n) MMap<K, V>
Return a new collection with the last n elements removed.
inherited
dropWhile(Function1<(K, V), bool> p) MMap<K, V>
Returns a new collection with leading elements satisfying p removed.
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 p in place and returns this.
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 satisfies p, None is returned.
inherited
flatMap<B>(covariant Function1<(K, V), RIterableOnce<B>> f) RIterable<B>
Returns a new collection by applying f to 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 op to all elements of this collection, moving from left to right. The fold uses a seed value of z.
inherited
foldRight<B>(B z, Function2<(K, V), B, B> op) → B
Returns a summary value by applying op to all elements of this collection, moving from right to left. The fold uses a seed value of z.
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 f to each element of this collection, discarding any resulting values.
inherited
get(K key) Option<V>
Returns the value for the given key key as 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, or orElse if this map doesn't contain the key.
inherited
getOrElseUpdate(K key, Function0<V> defaultValue) → V
Returns the value for key, or inserts and returns defaultValue when 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 f to 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 size elements from the original collection. The last element may contain less than size elements.
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 key and f. 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 key to each element. Additionally f is applied to each element to generate a value. If multiple values are generating for the same key, those values will be combined using reduce.
inherited
map<B>(Function1<(K, V), B> f) RIterable<B>
Returns a new collection by applying f to 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 f to 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 f to 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 sep between each element. If start is defined, it will be prepended to the resulting string. If end is 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 satisfy p.
inherited
partitionMap<A1, A2>(Function1<(K, V), Either<A1, A2>> f) → (RIterable<A1>, RIterable<A2>)
Applies f to 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 key with value, returning the previous value as Some, or None if key was not present.
override
reduce(Function2<(K, V), (K, V), (K, V)> op) → (K, V)
Reduces this collection to a single value by applying op left 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 f to 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 f to 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 f to each element, moving right to left.
inherited
remove(K key) Option<V>
Removes key and returns its value as Some, or None if absent.
override
removeAll(RIterableOnce<K> key) MMap<K, V>
Removes all of the given keys and returns this.
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 n of the original collection. Each chunk is calculated by sliding a 'window' of size n over the original collection, moving the window step elements 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 n elements and the remainder.
inherited
take(int n) MMap<K, V>
Returns a new collection containing only the first n elements.
inherited
takeRight(int n) MMap<K, V>
Returns a new collection with the last n elements of this collection. If n is 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 f to 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<(A, B)>, provided by the RIterableTuple2Ops extension

Creates a new IMap where each tuple element of this list is used to create a key and value respectively.
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<(A, B)>, provided by the RibsIterableTuple2Ops extension

Splits a collection of pairs into two separate collections.
update(K key, V value) → void
Sets key to value. Alias for put.
inherited
updateWith(K key, Function1<Option<V>, Option<V>> remappingFunction) Option<V>
Computes a new value for key by applying remappingFunction to 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 f for missing keys.
inherited
withDefaultValue(V value) MMap<K, V>
Returns a view of this map where key lookups return value for missing keys.
inherited
zip<B>(RIterableOnce<B> that) RIterable<((K, V), B)>
Returns a new collection that combines corresponding elements from this collection and that as a tuple. The length of the returned collection will be the minimum of this collections size and the size of that.
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 that as a tuple. The length of the returned collection will be the maximum of this collections size and thes size of that. If this collection is shorter than that, thisElem will be used to fill in the resulting collection. If that is shorter, thatElem will 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 key to value. Alias for update.
inherited

Static Methods

empty<K, V>() MHashMap<K, V>
Returns an empty MHashMap with default capacity and load factor.
override

Constants

DefaultInitialCapacity → const int
DefaultLoadFactor → const double