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 开发者_C百科be an efficient implementation in Foundation somewhere.
So, how do I access it?
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.
精彩评论