modSet<T> static method

Set<T> modSet<T>(
  1. Set<T> initial,
  2. Iterable<T>? add,
  3. Iterable<T>? remove,
  4. bool where(
    1. T
    )?,
)

Implementation

static Set<T> modSet<T>(Set<T> initial, Iterable<T>? add, Iterable<T>? remove, bool Function(T)? where){
  if(add != null || remove != null || where != null){
    Set<T> copy = initial.toSet();

    if(add != null){
      copy.addAll(add);
    }

    if(remove != null){
      for(T item in remove){
        copy.remove(item);
      }
    }

    if(where != null){
      copy.removeWhere(where);
    }

    return copy;
  }

  return initial;
}