Skip to content
An Objective-C wrapper of CFBinaryHeap. Core Foundation priority queue implementation.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
MCBinaryHeap
MCBinaryHeapDemo Initial commit May 8, 2015
.gitignore Initial commit May 8, 2015
LICENSE
MCBinaryHeap.podspec Initial commit May 8, 2015
README.md

README.md

MCBinaryHeap License MIT

Badge w/ Version Badge w/ Platform

An Objective-C wrapper of CFBinaryHeap. Core Foundation priority queue implementation.

Installation

Add the following to your CocoaPods Podfile

pod 'MCBinaryHeap', '~> 0.1'

or clone as a git submodule,

or just copy files in the MCBinaryHeap folder into your project.

Using MCBinaryHeap

Objects you add to MCBinaryHeap must implement - (NSComparisonResult)compare:(id)otherObject;.

The usage is very similar to NSMutableArray.

MCBinaryHeap *heap = [MCBinaryHeap heapWithArray:@[@3, @4, @5, @2]];
[heap addObject:@(1)];
NSLog(@"heap count %lu", heap.count);

[heap enumerateObjectsUsingBlock: ^(id object) {
    NSLog(@"heap item %@", object);
}];

NSLog(@"min object %@", [heap popMinimumObject]);

See the demo project for more details.

License

MCBinaryHeap is under the MIT license.

You can’t perform that action at this time.