Swiftpack.co - gabriel/GHODictionary as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by gabriel.
gabriel/GHODictionary 1.2.0
Ordered dictionary
⭐️ 12
🕓 2 years ago
iOS macOS tvOS
.package(url: "https://github.com/gabriel/GHODictionary.git", from: "1.2.0")

GHODictionary

Ordered dictionary. Enumeration occurs in the order that entries were added. If an item is overwritten, the order is unchanged.

For example,

#import <GHODictionary/GHODictionary.h>

GHODictionary *dict = [GHODictionary dictionary];
dict[@"key1"] = @(1);
dict[@"key2"] = @(2);
dict[@"key1"] = @(3);

for (id key in dict) ... // @"key1", @"key2"

[dict allKeys]; // The same as enumeration, @"key1", @"key2"

[dict map:^(id key, id value) { ... }]; // (@"key1", @(3)), (@"key2", @(2))

If you want to overwrite a value and have it moved to the end of the ordering, then remove it and re-add:

dict[@"key1"] = nil;
dict[@"key1"] = @(3);
[dict allKeys]; // @"key2", @"key1"

Because it is ordered, it is also sortable:

dict[@"b"] = @(2);
dict[@"c"] = @(3);
dict[@"a"] = @(1);
[dict sortKeysUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

[dict allKeys]; // @"a", @"b", @"c"

Swift Package Manager

.package(url: "https://github.com/gabriel/GHODictionary", from: "1.2.0"),

Podfile

pod "GHODictionary"

Cartfile

github "gabriel/GHODictionary"

GitHub

link
Stars: 12
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.2.0
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics