mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-05 20:22:15 +00:00
43 lines
788 B
Objective-C
43 lines
788 B
Objective-C
#import "BITOrderedDictionary.h"
|
|
|
|
@implementation BITOrderedDictionary
|
|
|
|
- (instancetype)init {
|
|
if (self = [super init]) {
|
|
dictionary = [NSMutableDictionary new];
|
|
order = [NSMutableArray new];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithCapacity:(NSUInteger)numItems {
|
|
self = [super init];
|
|
if ( self != nil )
|
|
{
|
|
dictionary = [[NSMutableDictionary alloc] initWithCapacity:numItems];
|
|
order = [NSMutableArray new];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)setObject:(id)anObject forKey:(id)aKey {
|
|
if(!dictionary[aKey]) {
|
|
[order addObject:aKey];
|
|
}
|
|
dictionary[aKey] = anObject;
|
|
}
|
|
|
|
- (NSEnumerator *)keyEnumerator {
|
|
return [order objectEnumerator];
|
|
}
|
|
|
|
- (id)objectForKey:(id)key {
|
|
return dictionary[key];
|
|
}
|
|
|
|
- (NSUInteger)count {
|
|
return [dictionary count];
|
|
}
|
|
|
|
@end
|