2019-05-16 13:53:15 -04:00
|
|
|
/** Interface for NSOrderedSet, NSMutableOrderedSet for GNUStep
|
2019-05-17 20:17:10 -04:00
|
|
|
Copyright (C) 2019 Free Software Foundation, Inc.
|
2019-05-16 13:53:15 -04:00
|
|
|
|
2019-05-17 20:17:10 -04:00
|
|
|
Written by: Gregory John Casamento <greg.casamento@gmail.com>
|
|
|
|
Created: May 17 2019
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
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 Lesser 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
|
2019-12-09 18:36:00 -05:00
|
|
|
Lesser General Public License for more details.
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
2024-11-07 13:37:59 +00:00
|
|
|
Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
2019-06-27 02:00:14 -04:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
|
|
|
|
|
2019-05-16 13:53:15 -04:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2019-06-07 05:36:53 -04:00
|
|
|
#import <GNUstepBase/GSBlocks.h>
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
2019-05-20 01:43:06 -04:00
|
|
|
#import <Foundation/NSIndexSet.h>
|
|
|
|
#import <Foundation/NSKeyedArchiver.h>
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2024-11-16 07:06:27 -05:00
|
|
|
|
2019-05-16 13:53:15 -04:00
|
|
|
@class GS_GENERIC_CLASS(NSArray, ElementT);
|
|
|
|
@class GS_GENERIC_CLASS(NSEnumerator, ElementT);
|
|
|
|
@class GS_GENERIC_CLASS(NSSet, ElementT);
|
|
|
|
@class GS_GENERIC_CLASS(NSDictionary, KeyT:id<NSCopying>, ValT);
|
|
|
|
@class NSString;
|
2019-05-17 20:17:10 -04:00
|
|
|
@class NSPredicate;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
2021-01-18 14:20:14 +01:00
|
|
|
GS_EXPORT_CLASS
|
2019-05-16 13:53:15 -04:00
|
|
|
@interface GS_GENERIC_CLASS(NSOrderedSet, __covariant ElementT) : NSObject <NSCoding,
|
|
|
|
NSCopying,
|
|
|
|
NSMutableCopying,
|
|
|
|
NSFastEnumeration>
|
|
|
|
|
|
|
|
// class methods
|
2024-11-17 10:17:46 -05:00
|
|
|
/**
|
|
|
|
* Create and return an empty ordered set.
|
|
|
|
*/
|
2019-05-16 13:53:15 -04:00
|
|
|
+ (instancetype) orderedSet;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an empty ordered set with the provided NSArray instance.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an empty ordered set with the provided NSArray instance.
|
|
|
|
* Use the range to determine which elements to use. If flag is YES copy the
|
|
|
|
* elements.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with anObject as the sole member.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with list of arguments starting with
|
|
|
|
* firstObject and terminated with nil.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithObjects: (GS_GENERIC_TYPE(ElementT))firstObject, ...;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set using the C array of objects with count.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger) count;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with the provided ordered set aSet.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with set aSet.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with the elements in aSet. If flag is YES,
|
|
|
|
* copy the elements.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
+ (instancetype) orderedSetWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet
|
|
|
|
copyItems: (BOOL)flag;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
// instance methods
|
2024-11-17 10:17:46 -05:00
|
|
|
/**
|
|
|
|
* Initialize and return an empty ordered set with the provided NSArray instance.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an empty ordered set with the provided NSArray instance.
|
|
|
|
* If flag is YES copy the elements.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array copyItems: (BOOL)flag;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an empty ordered set with the provided NSArray instance.
|
|
|
|
* Use the range to determine which elements to use. If flag is YES copy the
|
|
|
|
* elements.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with anObject as the sole member.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithObject: (id)object;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with list of arguments starting with
|
|
|
|
* firstObject and terminated with nil.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithObjects: (GS_GENERIC_TYPE(ElementT))firstObject, ...;
|
|
|
|
- (instancetype) initWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger)count;
|
2024-11-17 10:17:46 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set using the C array of objects with count.
|
|
|
|
*/
|
2024-11-16 07:06:27 -05:00
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
|
|
|
|
copyItems: (BOOL)flag;
|
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
|
|
|
- (instancetype) initWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
|
|
|
- (instancetype) initWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet copyItems:(BOOL)flag;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (instancetype) init;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (NSUInteger) count;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (BOOL)containsObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
|
|
|
- (void) enumerateObjectsAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSEnumeratorBlock)aBlock;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (void) enumerateObjectsWithOptions: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSEnumeratorBlock)aBlock;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) firstObject;
|
|
|
|
- (GS_GENERIC_TYPE(ElementT)) lastObject;
|
|
|
|
- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (NSUInteger)index;
|
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT)*) objectsAtIndexes: (NSIndexSet *)indexes;
|
|
|
|
- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))objects;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (NSUInteger) indexOfObject: (id)key
|
2024-11-16 07:06:27 -05:00
|
|
|
inSortedRange: (NSRange)range
|
|
|
|
options: (NSBinarySearchingOptions)options
|
|
|
|
usingComparator: (NSComparator)comparator;
|
|
|
|
|
|
|
|
- (NSUInteger) indexOfObjectAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
|
|
|
- (NSUInteger) indexOfObjectPassingTest: (GSPredicateBlock)predicate;
|
|
|
|
- (NSUInteger) indexOfObjectWithOptions: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
|
|
|
- (NSIndexSet *) indexesOfObjectsAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
|
|
|
|
|
|
|
- (NSIndexSet *)indexesOfObjectsPassingTest: (GSPredicateBlock)predicate;
|
|
|
|
- (NSIndexSet *) indexesOfObjectsWithOptions: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) objectEnumerator;
|
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator;
|
2019-05-18 03:56:11 -04:00
|
|
|
- (NSOrderedSet *)reversedOrderedSet;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer
|
2024-11-16 07:06:27 -05:00
|
|
|
range: (NSRange)aRange;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
// Key value coding support
|
2019-07-10 11:39:43 +02:00
|
|
|
- (void) setValue: (id)value forKey: (NSString*)key;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (id) valueForKey: (NSString*)key;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
// Comparing Sets
|
|
|
|
- (BOOL) isEqualToOrderedSet: (NSOrderedSet *)aSet;
|
2024-11-16 07:06:27 -05:00
|
|
|
|
2019-05-16 13:53:15 -04:00
|
|
|
// Set operations
|
|
|
|
- (BOOL) intersectsOrderedSet: (NSOrderedSet *)aSet;
|
2019-05-27 07:40:18 -04:00
|
|
|
- (BOOL) intersectsSet: (NSSet *)aSet;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (BOOL) isSubsetOfOrderedSet: (NSOrderedSet *)aSet;
|
2019-05-27 07:40:18 -04:00
|
|
|
- (BOOL) isSubsetOfSet:(NSSet *)aSet;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
// Creating a Sorted Array
|
2024-11-16 07:06:27 -05:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingDescriptors: (NSArray *)sortDescriptors;
|
2019-05-16 13:53:15 -04:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingComparator:
|
|
|
|
(NSComparator)comparator;
|
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *)
|
|
|
|
sortedArrayWithOptions: (NSSortOptions)options
|
2024-11-16 07:06:27 -05:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2019-05-16 13:53:15 -04:00
|
|
|
|
|
|
|
// Filtering Ordered Sets
|
|
|
|
- (NSOrderedSet *)filteredOrderedSetUsingPredicate: (NSPredicate *)predicate;
|
|
|
|
|
|
|
|
// Describing a set
|
|
|
|
- (NSString *) description;
|
|
|
|
- (NSString *) descriptionWithLocale: (NSLocale *)locale;
|
2019-05-20 04:01:20 -04:00
|
|
|
- (NSString *) descriptionWithLocale: (NSLocale *)locale indent: (BOOL)flag;
|
2019-06-07 22:39:51 -04:00
|
|
|
|
|
|
|
// Convert to other types
|
2022-02-14 10:23:46 +01:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) array;
|
|
|
|
- (GS_GENERIC_CLASS(NSSet, ElementT) *) set;
|
2019-05-16 13:53:15 -04:00
|
|
|
@end
|
2019-05-16 14:03:53 -04:00
|
|
|
|
|
|
|
// Mutable Ordered Set
|
2021-01-18 14:20:14 +01:00
|
|
|
GS_EXPORT_CLASS
|
2019-07-09 17:19:22 +02:00
|
|
|
@interface GS_GENERIC_CLASS(NSMutableOrderedSet, ElementT) : GS_GENERIC_CLASS(NSOrderedSet, ElementT)
|
2019-05-17 20:17:10 -04:00
|
|
|
// Creating a Mutable Ordered Set
|
|
|
|
+ (instancetype)orderedSetWithCapacity: (NSUInteger)capacity;
|
|
|
|
- (instancetype)initWithCapacity: (NSUInteger)capacity;
|
|
|
|
- (instancetype) init;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (void)addObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
|
|
|
- (void)addObjects: (const GS_GENERIC_TYPE(ElementT)[])objects count: (NSUInteger)count;
|
|
|
|
- (void)addObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray;
|
|
|
|
- (void)insertObject: (GS_GENERIC_TYPE(ElementT))object atIndex: (NSUInteger)index;
|
|
|
|
- (void)setObject: (GS_GENERIC_TYPE(ElementT))object atIndexedSubscript: (NSUInteger)index;
|
|
|
|
- (void)insertObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)array atIndexes: (NSIndexSet *)indexes;
|
|
|
|
- (void)removeObject: (GS_GENERIC_TYPE(ElementT))object;
|
|
|
|
- (void)removeObjectAtIndex: (NSUInteger)index;
|
|
|
|
- (void)removeObjectsAtIndexes: (NSIndexSet *)indexes;
|
|
|
|
- (void)removeObjectsInArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray;
|
|
|
|
- (void)removeObjectsInRange: (NSRange)range;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (void)removeAllObjects;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (void)replaceObjectAtIndex: (NSUInteger)index
|
|
|
|
withObject: (GS_GENERIC_TYPE(ElementT))object;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes
|
2024-11-16 07:06:27 -05:00
|
|
|
withObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects;
|
|
|
|
- (void) replaceObjectsInRange: (NSRange)range
|
|
|
|
withObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger)count;
|
|
|
|
- (void)setObject: (GS_GENERIC_TYPE(ElementT))object atIndex: (NSUInteger)index;
|
|
|
|
- (void)moveObjectsAtIndexes: (NSIndexSet *)indexes toIndex: (NSUInteger)index;
|
|
|
|
- (void) exchangeObjectAtIndex: (NSUInteger)index withObjectAtIndex: (NSUInteger)otherIndex;
|
|
|
|
- (void)filterUsingPredicate: (NSPredicate *)predicate;
|
|
|
|
- (void) sortUsingDescriptors: (NSArray *)descriptors;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (void) sortUsingComparator: (NSComparator)comparator;
|
|
|
|
- (void) sortWithOptions: (NSSortOptions)options
|
2024-11-16 07:06:27 -05:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (void) sortRange: (NSRange)range
|
2024-11-16 07:06:27 -05:00
|
|
|
options: (NSSortOptions)options
|
2019-05-17 20:17:10 -04:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2024-11-16 07:06:27 -05:00
|
|
|
- (void) intersectOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
|
|
|
- (void) intersectSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
|
|
|
- (void) minusOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
|
|
|
- (void) minusSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
|
|
|
- (void) unionOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
|
|
|
- (void) unionSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2019-05-17 20:17:10 -04:00
|
|
|
- (instancetype) initWithCoder: (NSCoder *)coder;
|
2019-05-16 14:03:53 -04:00
|
|
|
@end
|
2019-05-17 20:17:10 -04:00
|
|
|
|
2019-06-13 18:58:50 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
2019-05-17 20:17:10 -04:00
|
|
|
#endif
|
2019-06-13 18:58:50 -04:00
|
|
|
|
2019-06-27 02:00:14 -04:00
|
|
|
#endif /* OS_API_VERSION check */
|
|
|
|
|
2019-06-13 18:58:50 -04:00
|
|
|
#endif /* _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE */
|