auto<K, V> static method

Map<K, V> auto<K, V>(
  1. Map<K, V> creator()
)

Returns a map that will be created only when necessary, such as

  • Map.putIfAbsent is called.
  • It assumes the map was empty, and creates by invoking creator
  • when necessary. Don't use this method if the map already exists.
  • It is useful to save the memory, if you have a map that won't contain
  • anything in most case.
  • Notice you don't have to keep the object being returned by this method,
  • since it is just a proxy to the real map.
  • Refer to Rikulo UI's View.dataset for a sample implementation.

Implementation

static Map<K, V> auto<K, V>(Map<K, V> creator()) => _OnDemandMap(creator);