What is the LinkedList equivalent in iOS infrastructures?

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?

+8
java list ios objective-c cocoa
source share
4 answers

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.

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 .

+16
source share

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

+12
source share

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 .

+4
source share

NSMutableArray is a vector or dynamic array, but it is not a linked list.

+1
source share

All Articles