This is a very newbie questions, but does the iPhone API provide any data structures to work with (i.e. linked list, hash map, etc.)?
You can use any data structure implemented on C or C++ with iPhone SDK.
For example, I use STL a lot.
Besides that, you can also use Cocoa's complex data structures available like:
- NSArray
- NSDictionary (hash)
- NSSet (set)
You can have a companion document on them here.
The Objective-C language does not provide any inherent data structures like Linked Lists, etc. However, as it is based off of the C/C++ codebase, anything that can be implemented in C or C++ can be done directly in Objective-C, including Linked Lists and other data structures.
Cocoa (a framework available both on Mac and iPhone) implements several common collection types, including NSArray, NSDictionary, and NSSet, as well as their mutable variants. (Leopard also introduced NSHashMap, NSHashTable, and NSPointerArray, which use weak references. However, these classes aren't currently available on iPhone, and would make little sense at the moment, since iPhone OS doesn't support garbage collection.) These classes are extremely fast, and are suitable for general-purpose use in any Cocoa application.
Beyond these provided structures, you have several choices: (1) create more complex structures using these as building blocks, (2) leverage existing third-party code, or (3) build your own data structures from scratch.
One option is CHDataStructures.framework, an open-source Objective-C framework which I maintain. It implements several other common data structures, such as stack/queue/deque, linked lists, sorted sets, and more. These structures adopt NSCoding and NSCopying (plus NSFastEnumeration on 10.5+), so they work seamlessly with native Objective-C code. The project allows you to build a static library for use on iPhone as well. Since this framework is open source, you can even include only the relevant code directly in your project if needed.
While you can use C++ and STL structures, I have found that mixing Objective-C and C++ tends to be more confusing and lead to in vexing bugs, especially for novices. This isn't a bash against C++, just a "when in Rome" principle. When using C++, STL is of course the preferred approach.