In java, you can use the generic LinkedList to improve performance when objects are often added to the top of the list. What is its equivalent in iOS?
LinkedList
You need to understand that in Foundation classes such as NSArray , etc., this is not what you learned as an array, etc. in your elementary programming class. In particular, it does not have which are usually associated with an array.
NSArray
There are a lot of good blog posts at this point, for example. one of Ridiculous Fish and the other Cocoa with love
So, like everyone else, just use NSMutableArray .
NSMutableArray
NSMutableArray is closest to this. Despite the name, it is closer to the list than an array. However, "adding and removing elements from either end takes a constant time," according to this .
Also, what about this, a third-party implementation: https://github.com/mschettler/NSLinkedList
There is no direct equivalent. Writing a linked list is very easy, but I doubt you will get more performance than NSMutableArray .
There are several different implementations of linked lists in open source CHDataStructures .
NSMutableArray is a vector or dynamic array, but it is not a linked list.