Function areSetsDisjoint

  • Checks if two sets are disjoint; that is, if both sets have no elements in common.

    • Formal definition: A ∩ B = ϕ
    • This method runs in bilinear time, or O(m * n), where m = |B| (size of set B) and n = |A| (size of set A).

    Type Parameters

    • TElement

    Parameters

    • a: Set<TElement>

      Set A of type <TElement> elements

    • b: Set<TElement>

      Set B of type <TElement> elements

    Returns boolean

    Whether A ∩ B = ϕ is true

    See

    Set.prototype.isDisjointFrom

    Example

    // {1, 2, 3} ∩ {4, 5, 6} = ϕ
    areSetsDisjoint(new Set([1, 2, 3]), new Set([4, 5, 6])); // true

    // {1, 2, 3} ∩ {3, 4, 5} ≠ ϕ
    areSetsDisjoint(new Set([1, 2, 3]), new Set([3, 4, 5])); // false

Generated using TypeDoc