toMap method

Map<K, V> toMap()

Converts to a Map.

Note that the implementation is efficient: it returns a copy-on-write wrapper around the data from this BuiltMap. So, if no mutations are made to the result, no copy is made.

This allows efficient use of APIs that ask for a mutable collection but don't actually mutate it.

Implementation

Map<K, V> toMap() => CopyOnWriteMap<K, V>(_map, _mapFactory);