Beispiel #1
0
 /// <summary>
 /// Atomically sets an item by first retrieving it, applying a map, and then putting it back.
 /// Calls the None delegate to return a new map if the item can't be found
 /// </summary>
 /// <remarks>Null is not allowed for a Key or a Value</remarks>
 /// <param name="key">Key</param>
 /// <param name="Some">delegate to map the existing value to a new one before setting</param>
 /// <param name="None">delegate to return a new map if the item can't be found</param>
 /// <exception cref="Exception">Throws Exception if Some returns null</exception>
 /// <exception cref="Exception">Throws Exception if None returns null</exception>
 /// <returns>New map with the item set</returns>
 public static Map <K, V> trySetItem <K, V>(Map <K, V> map, K key, Func <V, V> Some, Func <Map <K, V>, Map <K, V> > None) =>
 map.TrySetItem(key, Some, None);
Beispiel #2
0
 /// <summary>
 /// Atomically updates an existing item, unless it doesn't exist, in which case
 /// it is ignored
 /// </summary>
 /// <remarks>Null is not allowed for a Key or a Value</remarks>
 /// <param name="key">Key</param>
 /// <param name="value">Value</param>
 /// <exception cref="ArgumentNullException">Throws ArgumentNullException the value is null</exception>
 /// <returns>New Map with the item added</returns>
 public static Map <K, V> trySetItem <K, V>(Map <K, V> map, K key, V value) =>
 map.TrySetItem(key, value);