JTBinaryHeap
A simple Objective-C wrapper for CFBinaryHeap for use in both Objective-C/Swift projects. This is effectively a min-heap.
Usage
- Import the data structure
#import "JTBinaryHeap"
- Add items to it using
addValue:
- Use
minimumValue
orextractMinimumValue
to 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"
Swift Notes
- Import the data structure
import JTBinaryHeap
into your swift files - Add items using
addValue(...)
- Use
minimumValue
orextractMinimumValue
to get the smallest value in the min-heap.
var heap = JTBinaryHeap()
heap.addValue("Banana")
heap.addValue("Dinosaur")
let minimumValue = head.minimumValue()