2005-08-30 14:54:43 +00:00
|
|
|
/* Interface for NSSortDescriptor for GNUStep
|
|
|
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Saso Kiselkov <diablos@manga.sk>
|
|
|
|
Date: 2005
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
2006-03-08 11:28:59 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02111 USA.
|
2005-08-30 14:54:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NSSortDescriptor_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSSortDescriptor_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-10-25 21:26:04 +00:00
|
|
|
#if OS_API_VERSION(100300,GS_API_LATEST)
|
|
|
|
|
2005-08-30 14:54:43 +00:00
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
@interface NSSortDescriptor : NSObject <NSCopying, NSCoding>
|
|
|
|
{
|
2006-10-25 21:26:04 +00:00
|
|
|
NSString *_key;
|
|
|
|
BOOL _ascending;
|
|
|
|
SEL _selector;
|
2005-08-30 14:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) ascending;
|
2006-10-25 21:26:04 +00:00
|
|
|
- (NSComparisonResult) compareObject: (id) object1 toObject: (id) object2;
|
|
|
|
- (id) initWithKey: (NSString *)key
|
|
|
|
ascending: (BOOL)ascending;
|
|
|
|
- (id) initWithKey: (NSString *)key
|
|
|
|
ascending: (BOOL)ascending
|
|
|
|
selector: (SEL)selector;
|
2005-08-30 14:54:43 +00:00
|
|
|
- (NSString *) key;
|
|
|
|
- (SEL) selector;
|
|
|
|
- (id) reversedSortDescriptor;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSArray (NSSortDescriptorSorting)
|
|
|
|
|
2006-10-25 21:26:04 +00:00
|
|
|
- (NSArray *) sortedArrayUsingDescriptors: (NSArray *)sortDescriptors;
|
2005-08-30 14:54:43 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSMutableArray (NSSortDescriptorSorting)
|
|
|
|
|
2006-10-26 08:33:40 +00:00
|
|
|
/**
|
|
|
|
* This method works like this: first, it sorts the entire
|
|
|
|
* contents of the array using the first sort descriptor. Then,
|
|
|
|
* after each sort-run, it looks whether there are sort
|
|
|
|
* descriptors left to process, and if yes, looks at the partially
|
|
|
|
* sorted array, finds all portions in it which are equal
|
|
|
|
* (evaluate to NSOrderedSame) and applies the following
|
|
|
|
* descriptor onto them. It repeats this either until all
|
|
|
|
* descriptors have been applied or there are no more equal
|
|
|
|
* portions (equality ranges) left in the array.
|
|
|
|
*/
|
2006-10-25 21:26:04 +00:00
|
|
|
- (void) sortUsingDescriptors: (NSArray *)sortDescriptors;
|
2005-08-30 14:54:43 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-25 21:26:04 +00:00
|
|
|
#endif
|
|
|
|
|
2005-08-30 14:54:43 +00:00
|
|
|
#endif /* __NSSortDescriptor_h_GNUSTEP_BASE_INCLUDE */
|