getMatchingAttributionsWithin method

Set<Attribution> getMatchingAttributionsWithin({
  1. required Set<Attribution> attributions,
  2. required int start,
  3. required int end,
})

Finds and returns all Attributions in this AttributedSpans that match any of the given attributions.

Two Attributions are said to "match" if their ids are equal.

Implementation

Set<Attribution> getMatchingAttributionsWithin({
  required Set<Attribution> attributions,
  required int start,
  required int end,
}) {
  final matchingAttributions = <Attribution>{};
  for (int i = start; i <= end; ++i) {
    for (final attribution in attributions) {
      final otherAttributions = getAllAttributionsAt(i);
      for (final otherAttribution in otherAttributions) {
        if (otherAttribution.id == attribution.id) {
          matchingAttributions.add(otherAttribution);
        }
      }
    }
  }
  return matchingAttributions;
}