Class SetMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
com.tangosol.util.SetMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class SetMap<K,V> extends AbstractMap<K,V>
A Map implementation based on a known set of keys and a Function that when given a key can derive the value. Once a value has been derived for a key the function will not be called again for the same key.

This map can be mutated outside of the original set of keys or within the set of keys. The latter will result in the function not being called for the respective keys.

This implementation is the inverse to a MapSet which can trivially distill a Map of keys and values to a Set of keys. With the use of a Function this implementation allows a Set of keys to be converted lazily to a Map of keys and values.

Since:
12.2.1.4.0
Author:
hr 2016.09.29
  • Field Details

    • f_map

      protected Map<K,Object> f_map
      The underlying map.
    • f_functionValue

      protected Function<K,V> f_functionValue
      A function to load a value for a provided key.
  • Constructor Details

    • SetMap

      public SetMap(Set<K> setKeys)
      Construct a SetMap.
      Parameters:
      setKeys - a set of keys to base this Map on
    • SetMap

      public SetMap(Set<K> setKeys, Function<K,V> functionValue)
      Construct a SetMap.
      Parameters:
      setKeys - a set of keys to base this Map on
      functionValue - a Function to derive the value for a given key
    • SetMap

      public SetMap(Set<K> setKeys, Function<K,V> functionValue, Supplier<Map<K,V>> supplierMap)
      Construct a SetMap.
      Parameters:
      setKeys - a set of keys to base this Map on
      functionValue - a Function to derive the value for a given key
      supplierMap - the Map to use to hold keys and values
  • Method Details