Add implementation of array and set methods.

This commit is contained in:
Gregory John Casamento 2019-06-07 22:39:51 -04:00
parent bb6f7ceed8
commit 2dccb2eee6
2 changed files with 37 additions and 1 deletions

View file

@ -158,6 +158,10 @@ extern "C" {
- (NSString *) description;
- (NSString *) descriptionWithLocale: (NSLocale *)locale;
- (NSString *) descriptionWithLocale: (NSLocale *)locale indent: (BOOL)flag;
// Convert to other types
- (NSArray *) array;
- (NSSet *) set;
@end
// Mutable Ordered Set

View file

@ -1133,7 +1133,11 @@ static SEL rlSel;
// Creating a Sorted Array
- (NSArray *) sortedArrayUsingDescriptors:(NSArray *)sortDescriptors
{
return nil;
NSMutableArray *sortedArray = [GSMutableArray arrayWithArray: [self array]];
[sortedArray sortUsingDescriptors: sortDescriptors];
return GS_IMMUTABLE(sortedArray);
}
- (NSArray *) sortedArrayUsingComparator: (NSComparator)comparator
@ -1182,6 +1186,34 @@ static SEL rlSel;
{
return [self descriptionWithLocale: locale];
}
- (NSArray *) array
{
NSEnumerator *en = [self objectEnumerator];
NSMutableArray *result = [NSMutableArray arrayWithCapacity: [self count]];
id o = nil;
while((o = [en nextObject]) != nil)
{
[result addObject: o];
}
return GS_IMMUTABLE(result);
}
- (NSSet *) set
{
NSEnumerator *en = [self objectEnumerator];
NSMutableSet *result = [NSMutableSet setWithCapacity: [self count]];
id o = nil;
while((o = [en nextObject]) != nil)
{
[result addObject: o];
}
return GS_IMMUTABLE(result);
}
@end
// Mutable Ordered Set