subtractAll method

Queue<E> subtractAll(
  1. Iterable<E> elementsToRemove, {
  2. bool equalityFunction(
    1. E a,
    2. E b
    ) = h.symmetricDeepEquals,
})

Removes all elements if they are in elementsToRemove.

1, 1, 2, 2, 3, 3.subtractAll(1, 2) returns 3, 3.

[{1,2}, {1,2}, 3,4].subtractAll({1,2}) returns [3,4].

To determine which elements to subtract, h.symmetricDeepEquals uses DeepCollectionEquality().equals in both directions since normally it is asymmetrical. If using a custom equalityFunction, elements are compared with the element in the original being the first argument, and element in elementsToSubtract being the second.

subtract would only remove one element at a time instead of all occurrences.

Implementation

Queue<E> subtractAll(
  Iterable<E> elementsToRemove, {
  bool Function(E a, E b) equalityFunction = h.symmetricDeepEquals,
}) {
  return h
      .iterableSubtractAll(
        original: this,
        elementsToRemove: elementsToRemove,
        equalityFunction: equalityFunction,
      )
      .toQueue();
}