to_map


Description:

[ Version ( since = "0.4.0-alpha" ) ]
public Future<Map<K,V>> to_map<K,V> (owned MapFunc<K,G> key_mapper, owned MapFunc<V,G> val_mapper, owned CombineFunc<V>? merger = null, owned HashDataFunc<K>? key_hash = null, owned EqualDataFunc<K>? key_equal = null, owned EqualDataFunc<V>? value_equal = null)

Accumulates the elements into a new map.

If there are key duplications, the values are merged using the merger function, or the future is completed with a MapError.DUPLICATE_KEY if the function is not specified.

There are no guarantees on the type, mutability, or thread-safety of the map.

This is equivalent to:

seq.collect( Collectors.to_map<K,V,G>(...) );

This is a terminal operation.

Parameters:

key_mapper

a mapping function for keys

val_mapper

a mapping function for values

merger

a function used to resolve key collisions. if not specified, (a, b) => { throw new MapError.DUPLICATE_KEY(...); } is used.

key_hash

a hash function for keys. if not specified, Gee.Functions.get_hash_func_for is used to get a proper function

key_equal

an equal function for keys. if not specified, Gee.Functions.get_equal_func_for is used to get a proper function

value_equal

an equal function for values. if not specified, Gee.Functions.get_equal_func_for is used to get a proper function

Returns:

a future of the result map

See also:

Collectors.to_map




2022 vala-language.org