toSet method

  1. @override
Set<E> toSet()
override

As Iterable.toSet.

Note that the implementation is efficient: it returns a copy-on-write wrapper around the data from this BuiltSet. So, if no mutations are made to the result, no copy is made.

This allows efficient use of APIs that ask for a mutable collection but don't actually mutate it.

Implementation

@override
Set<E> toSet() => CopyOnWriteSet<E>(_set, _setFactory);