Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Stack class in Objective C that I can import and use?

I need a stack ADT in my application. I would like to avoid making a wrapper on NSMutableArray; there must be an efficient implementation in Foundation somewhere.

So, how do I access it?

like image 762
Mazyod Avatar asked Apr 28 '11 23:04

Mazyod


1 Answers

You've got a couple of options; if you really want a stack, you could use std::stack from STL. Just be sure to include #import <stack> rename any .m files which use it to .mm.

The other option is to write an Objective-C class which either wraps std::stack, or provides a stack interface to NSMutableArray. I include this despite your wishes to the contrary, because unless you have actually profiled the code that uses NSMutableArray, you have absolutely no business complaining about its performance.

like image 108
Jonathan Sterling Avatar answered Nov 15 '22 00:11

Jonathan Sterling