Created
March 5, 2018 22:12
-
-
Save kalub92/d8f6f78a2688fc97c43fca39135c832f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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