Skip to content

Instantly share code, notes, and snippets.

@twzurkan
twzurkan / Heap.swift
Last active March 17, 2024 21:26
Swift Heap/PriorityQueue
/// This is a simple Heap implementation which can be used as a priority queue.
class Heap<T:Comparable> {
typealias HeapComparator<T:Comparable> = (_ l:T,_ r:T) -> Bool
var heap = [T]()
var count:Int {
get {
heap.count
}
}