Does the iOS SDK provide queues and stacks?

2019-03-11 15:40发布

I'm writing an iPhone app, and I'm surprised that there seem to be no NSQueue or NSStack classes in Apple's Foundation Framework. I see that it would be quite easy to roll my own, starting with an NSMutableArray, so I'll do that unless I've missed something. Have I missed something?

标签: stack queue ios
8条回答
小情绪 Triste *
2楼-- · 2019-03-11 16:24

I'm a bit late to this party, but are you aware of CHDataStructures?

http://cocoaheads.byu.edu/code/CHDataStructures

查看更多
女痞
3楼-- · 2019-03-11 16:26

Yes, an NSMutableArray doubles as a stack or queue. (It would be slightly inefficient as a queue.)

You could also use C++'s stack and queue adapter, but it makes memory management a bit messy if you want to store Objective-C objects with it.

查看更多
登录 后发表回答