A framework that provides some data structures to use on your project. The available structures are: Queue, Stack, Linked List and Doubly Linked List.
Every data structure has a set of common functions:
- append
- appendElementsOfArray
- remove
- firstIndexOf
and attributes:
- isEmpty
- count
Linked List and Doubly Linked List have extra functions:
- appendFirst
- appendAtIndex
- removeFirst
- removeLast
- removeAtIndex
and attributes:
- head
- tail
KStack<NSNumber *> * stack = [[KStack alloc] init];
NSLog(stack.isEmpty ? @"YES" : @"NO");
[stack append: @1];
[stack append: @2];
[stack append: @3];
NSLog(@"%@", stack);
NSLog(stack.isEmpty ? @"YES" : @"NO");
NSNumber * n = [stack remove];
NSLog(@"%@", n);
NSLog(@"%@", stack);
NSInteger index = [stack firstIndexOf: @1];
if (index == -1) {
NSLog(@"Element not found.");
} else {
NSLog(@"%ld", index);
}
Kollection is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Kollection'
Kollection is available under the MIT license. See the LICENSE file for more info.