A simple Objective-C wrapper for CFBinaryHeap for use in both Objective-C/Swift projects. This is effectively a min-heap.
- Import the data structure
#import "JTBinaryHeap" - Add items to it using
addValue: - Use
minimumValueorextractMinimumValueto get the smallest value in the min-heap.
JTBinaryHeap *heap = [[JTBinaryHeap alloc] init];
[heap addValue:@"Banana"];
[heap addValue:@"Dinosaur"];
NSString *minimumValue = [heap minimumValue]; //will be @"Banana"
- Import the data structure
import JTBinaryHeapinto your swift files - Add items using
addValue(...) - Use
minimumValueorextractMinimumValueto get the smallest value in the min-heap.
var heap = JTBinaryHeap()
heap.addValue("Banana")
heap.addValue("Dinosaur")
let minimumValue = head.minimumValue()