A Simple Objective-C Doubly Linked List
Objective-C Makefile
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
CKLinkedList-test.m
CKLinkedList.h
CKLinkedList.m
LICENSE.txt
Makefile
README.md

README.md

###A Doubly linked list for Objective-C

"The principal benefit of a linked list over a conventional array is that the order of the linked items may be different from the order that the data items are stored in memory or on disk. For that reason, linked lists allow insertion and removal of nodes at any point in the list, with a constant number of operations. On the other hand, linked lists by themselves do not allow random access to the data, or any form of efficient indexing. "

###Installation

  1. Add CKLinkedList.h and CKLinkedList.m to your project
  2. Add #import "CKLinkedList.h" to your project's .pch file
  3. CKLinkedList class is now available anywhere in your project, enjoy!

###Benefits vs. NSArray

  • Efficient insertion and removal of elements at any index
  • Efficient memory allocation (No need to resize/reallocate memory)

###Example Usage

CKLinkedList *myList = [[CKLinkedList alloc] init];

[myList addObject:obj2];  // add object to end of list
[myList addObject:obj3];  // add object to end of list
[myList pushFront:obj1];  // add object to front of list, no performance penalty

// linked list now contains obj1->obj2->obj3 in that order [NSStrings, or any object]

// manual loop through list, forward
for (LNode *n = myList->first; n; n=n->next) {
	NSString *theString = n->obj;
	NSLog(@"string: %@", theString);
}

// ...
// ...

[myList release];

###Testing

  • Execute make test to run the test suite