Skip to content

Instantly share code, notes, and snippets.

@Bouke

Bouke/README.md

Last active Aug 29, 2015
Embed
What would you like to do?
Binary Heap (Priority Queue) in Swift
@littlebobert

This comment has been minimized.

Copy link

@littlebobert littlebobert commented Aug 25, 2014

won't heapify fail to explore subtrees (that might violate min-heap properties) in the case where index is already the smallest? I guess it doesn't matter here since you only ever call heapify when the index is the only element that’s in violation…

@Bouke

This comment has been minimized.

Copy link
Owner Author

@Bouke Bouke commented Nov 2, 2014

This code was written when Swift didn't have access modifiers. Both var heap and func heapify are not part of the public API. You can only pop items onto the heap, so the result should always be a valid binary heap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.