Skip to content

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

License

Notifications You must be signed in to change notification settings

turtleeeeee/MCBinaryHeap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 88.6%
  • Ruby 11.4%