swap method

void swap(
  1. PriorityQueue<T> other
)

Exchanges the contents of this priority queue with those of other.

Implementation

void swap(PriorityQueue<T> other) {
  final tempHeap = _heap.toList();
  _heap.clear();
  _heap.addAll(other._heap);
  other._heap.clear();
  other._heap.addAll(tempHeap);
}