toSet method Null safety

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

Return a comparator based set using the comparator of this queue.

The queue is not modified.

The returned Set is currently a SplayTreeSet, but this may change as other ordered sets are implemented.

The set contains all the elements of this queue. If an element occurs more than once in the queue, the set will contain it only once.

Implementation

@override
Set<E> toSet() {
  var set = SplayTreeSet<E>(comparison);
  for (var i = 0; i < _length; i++) {
    set.add(_elementAt(i));
  }
  return set;
}