Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Min/Max Heap or Priority Queue data structure in Objective-C

Is there Min/Max Heap or Priority Queue like data structure provided by the system framework in Objective-C?

I can implement it myself or use a third party library, but I'm just curious if the system has already provide it like Java does.

like image 671
Scott Zhu Avatar asked Apr 14 '26 13:04

Scott Zhu


1 Answers

For priority queues: No. There is no generic standard in Cocoa, even classes as NSOperationQueue uses priority queues.

For min-max heaps: No. And you will never find. A min-max heap is a structure to implement a priority queue. Cocoa's APIs are never built on top of an implementation, but from the final collection. I. e. you have NSArray for ordered collections. There are several structures used for implementing that array. But you always get the final product NSArray independent of the structure used internally.

This is a design principle of Cocoa.

So, if someone (Apple, someone else, you) implements a priority queue, he likely uses min-max heaps. But you will never know, if it is implemented according to the concepts of Cocoa.

like image 119
Amin Negm-Awad Avatar answered Apr 17 '26 01:04

Amin Negm-Awad