mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Add implementation of array and set methods.
This commit is contained in:
parent
bb6f7ceed8
commit
2dccb2eee6
2 changed files with 37 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue