the key type
the value type
Used by the node REPL to display values. Most of the time should be the same as toString()
Returns true if the predicate returns true for all the elements in the collection.
Returns true if there the predicate returns true for any element in the collection.
Returns true if the item is in the collection, false otherwise.
Returns true if there is item with that key in the collection, false otherwise.
Two objects are equal if they represent the same value, regardless of whether they are the same object physically in memory.
Call a predicate for each element in the collection, build a new collection holding only the elements for which the predicate returned true.
Call a predicate for each key in the collection, build a new collection holding only the elements for which the predicate returned true.
Call a predicate for each value in the collection, build a new collection holding only the elements for which the predicate returned true.
Calls the function you give for each item in the map, your function returns a map, all the maps are merged.
Reduces the collection to a single value using the associative binary function you give. Since the function is associative, order of application doesn't matter.
Example:
HashSet.of(1,2,3).fold(0, (a,b) => a + b);
=> 6
Reduces the collection to a single value. Left-associative.
Example:
Vector.of("a", "b", "c").foldLeft("!", (xs,x) => x+xs);
=> "cba!"
The initial value
A function taking the previous value and the current collection item, and returning an updated value.
Reduces the collection to a single value. Right-associative.
Example:
Vector.of("a", "b", "c").foldRight("!", (x,xs) => xs+x)
=> "!cba"
The initial value
A function taking the current collection item and the previous value , and returning an updated value.
Call a function for element in the collection.
Get the value for the key you give, if the key is present.
Get a number for that object. Two different values may get the same number, but one value must always get the same number. The formula can impact performance.
true if the map is empty, false otherwise.
Get a Set containing all the keys in the map
number of items in the map
Return a new map where each entry was transformed by the mapper function you give. You return key,value as pairs.
Return a new map where keys are the same as in this one, but values are transformed by the mapper function you give. You return key,value as pairs.
Create a new map combining the entries of this map, and the other map you give. In case an entry from this map and the other map have the same key, the merge function will be invoked to get a combined value.
another map to merge with this one
a merge function to combine two values in case two entries share the same key.
Add a new entry in the map. If there was entry with the same key, it will be overwritten.
the key
the value
Add a new entry in the map; in case there was already an entry with the same key, the merge function will be invoked with the old and the new value to produce the value to take into account.
the key
the value
a function to merge old and new values in case of conflict.
Reduces the collection to a single value by repeatedly calling the combine function. No starting value. The order in which the elements are passed to the combining function is undetermined.
Return a new map with the key you give removed.
Convert to array.
Convert to an ES6 Map. You must provide a function to convert the key to a string, number or boolean, because with other types equality is not correctly managed by JS. https://stackoverflow.com/questions/29759480/how-to-customize-object-equality-for-javascript-set https://esdiscuss.org/topic/maps-with-object-keys
HashMap.of<string,number>(["a",1],["b",2])
.toJsMap(x=>x);
=> new Map([["a",1], ["b",2]])
Convert this map to a List of key,value pairs. Note that Map is already an iterable of key,value pairs!
Convert to a javascript object dictionary You must provide a function to convert the key to a string.
HashMap.of<string,number>(["a",1],["b",2])
.toObjectDictionary(x=>x);
=> {a:1,b:2}
Get a human-friendly string representation of that value.
Convert this map to a vector of key,value pairs. Note that Map is already an iterable of key,value pairs!
Transform this value to another value type. Enables fluent-style programming by chaining calls.
Get an iterable containing all the values in the map (can't return a set as we don't constrain map values to have equality in the generics type)
Generated using TypeDoc
A generic interface for a dictionary, mapping keys to values.