contains method
Creates a cell that is true if the value held in elem
is present in the set held in this
.
A mutable cell is created. When the value of the cell is set to true,
the value held in elem
is added to the set in this
. When the value of the
cell is set to false, the value held in elem
is removed from the set
held in this
.
A keyed cell is created.
Implementation
MutableCell<bool> contains(ValueCell<T> elem) =>
(this, elem).mutableApply((set, elem) => set.contains(elem), (bool inSet) {
final copy = Set<T>.from(value);
if (inSet) {
copy.add(elem.value);
}
else {
copy.remove(elem.value);
}
value = copy;
}, key: _MutableSetContainsKey(this, elem));