addOrUpdateWhere method

ImmortalSet<T> addOrUpdateWhere(
  1. bool predicate(
    1. T value
    ),
  2. T update(
    1. T value
    ),
  3. T ifAbsent()
)

Returns a copy of this set by applying update on each element that fulfills the given predicate, or adds the result of ifAbsent to the set if no element satisfying predicate was found.

Implementation

ImmortalSet<T> addOrUpdateWhere(
  bool Function(T value) predicate,
  T Function(T value) update,
  T Function() ifAbsent,
) =>
    any(predicate) ? updateWhere(predicate, update) : add(ifAbsent());