Skip to content

Instantly share code, notes, and snippets.

@kalub92
Created March 5, 2018 22:12
Show Gist options
  • Save kalub92/d8f6f78a2688fc97c43fca39135c832f to your computer and use it in GitHub Desktop.
Save kalub92/d8f6f78a2688fc97c43fca39135c832f to your computer and use it in GitHub Desktop.
mutating public func poll() -> Int {
if items.count != 0 {
let item = items[0]
items[0] = items[items.count - 1]
heapifyDown()
items.removeLast()
return item
} else {
fatalError()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment