IMap<K, V>.unsafe constructor

IMap<K, V>.unsafe(
  1. Map<K, V>? map, {
  2. required ConfigMap config,
})

Unsafe constructor. Use this at your own peril.

This constructor is fast, since it makes no defensive copies of the map. However, you should only use this with a new map you've created yourself, when you are sure no external copies exist. If the original map is modified, it will break the IMap and any other derived maps in unpredictable ways.

Also, if config is ConfigMap.sort true, it assumes you will pass it a sorted mao. It will not sort the map for you. In this case, if map is not sorted, it will break the IMap and any other derived sets in unpredictable ways.

Implementation

IMap.unsafe(Map<K, V>? map, {required this.config})
    : _m = (map == null) ? MFlat.empty<K, V>() : MFlat<K, V>.unsafe(map) {
  if (ImmutableCollection.disallowUnsafeConstructors)
    throw UnsupportedError("IMap.unsafe is disallowed.");
}