Spec-Zone.ru › Dart 2

dart:collection

Метод intersection

Set<E> intersection(
  1. Set<Object?> other
)
override

Создает новый набор, который является пересечением этого набора и other.

То есть, возвращаемый набор содержит все элементы этого набора, которые также являются элементами other в соответствии с other.contains.

final characters1 = <String>{'A', 'B', 'C'};
final characters2 = <String>{'A', 'E', 'F'};
final unionSet = characters1.intersection(characters2);
print(unionSet); // {A}

Реализация

Set<E> intersection(Set<Object?> other) {
  Set<E> result = SplayTreeSet<E>(_compare, _validKey);
  for (E element in this) {
    if (other.contains(element)) result.add(element);
  }
  return result;
}

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-collection/SplayTreeSet/intersection.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API