2019-05-16 17:53:15 +00:00
|
|
|
/** Interface for NSOrderedSet, NSMutableOrderedSet for GNUStep
|
2019-05-18 00:17:10 +00:00
|
|
|
Copyright (C) 2019 Free Software Foundation, Inc.
|
2019-05-16 17:53:15 +00:00
|
|
|
|
2019-05-18 00:17:10 +00:00
|
|
|
Written by: Gregory John Casamento <greg.casamento@gmail.com>
|
|
|
|
Created: May 17 2019
|
2019-05-16 17:53:15 +00: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 23:36:00 +00:00
|
|
|
Lesser General Public License for more details.
|
2019-05-16 17:53:15 +00: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 17:53:15 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
2019-06-27 06:00:14 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
|
|
|
|
|
2019-05-16 17:53:15 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2019-06-07 09:36:53 +00:00
|
|
|
#import <GNUstepBase/GSBlocks.h>
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
2019-05-20 05:43:06 +00:00
|
|
|
#import <Foundation/NSIndexSet.h>
|
|
|
|
#import <Foundation/NSKeyedArchiver.h>
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2024-11-16 12:06:27 +00:00
|
|
|
|
2019-05-16 17:53:15 +00: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-18 00:17:10 +00:00
|
|
|
@class NSPredicate;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
2024-11-17 17:04:24 +00:00
|
|
|
/**
|
|
|
|
* This class provides an ordered set, a set where the order of the elements matters and
|
|
|
|
* is preserved. Once created the set cannot be modified. NSMutableOrderedSet can be
|
|
|
|
* modified.
|
|
|
|
*/
|
2021-01-18 13:20:14 +00:00
|
|
|
GS_EXPORT_CLASS
|
2019-05-16 17:53:15 +00:00
|
|
|
@interface GS_GENERIC_CLASS(NSOrderedSet, __covariant ElementT) : NSObject <NSCoding,
|
|
|
|
NSCopying,
|
|
|
|
NSMutableCopying,
|
|
|
|
NSFastEnumeration>
|
|
|
|
|
|
|
|
// class methods
|
2024-11-17 15:17:46 +00:00
|
|
|
/**
|
|
|
|
* Create and return an empty ordered set.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
+ (instancetype) orderedSet;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an empty ordered set with the provided NSArray instance.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects;
|
2024-11-17 15:17:46 +00: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 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with anObject as the sole member.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with list of arguments starting with
|
|
|
|
* firstObject and terminated with nil.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithObjects: (GS_GENERIC_TYPE(ElementT))firstObject, ...;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set using the C array of objects with count.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger) count;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with the provided ordered set aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with set aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and return an ordered set with the elements in aSet. If flag is YES,
|
|
|
|
* copy the elements.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
+ (instancetype) orderedSetWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet
|
|
|
|
copyItems: (BOOL)flag;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// instance methods
|
2024-11-17 15:17:46 +00:00
|
|
|
/**
|
|
|
|
* Initialize and return an empty ordered set with the provided NSArray instance.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an empty ordered set with the provided NSArray instance.
|
|
|
|
* If flag is YES copy the elements.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array copyItems: (BOOL)flag;
|
2024-11-17 15:17:46 +00: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 12:06:27 +00:00
|
|
|
- (instancetype) initWithArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)array
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with anObject as the sole member.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithObject: (id)object;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with list of arguments starting with
|
|
|
|
* firstObject and terminated with nil.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithObjects: (GS_GENERIC_TYPE(ElementT))firstObject, ...;
|
|
|
|
- (instancetype) initWithObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger)count;
|
2024-11-17 15:17:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set using the C array of objects with count.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with the elements in aSet. If flag is YES,
|
|
|
|
* copy the elements.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 17:04:24 +00: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 12:06:27 +00:00
|
|
|
- (instancetype) initWithOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
|
|
|
|
range: (NSRange)range
|
|
|
|
copyItems: (BOOL)flag;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with set aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize and return an ordered set with set aSet. If flag is YES, then copy the elements.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (instancetype) initWithSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet copyItems:(BOOL)flag;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize an empty ordered set.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (instancetype) init;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the number of elements in the receiver.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (NSUInteger) count;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver contains anObject.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (BOOL)containsObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumerate over the objects whose indexes are contained in indexSet, with the opts provided
|
|
|
|
* using aBlock.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) enumerateObjectsAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSEnumeratorBlock)aBlock;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumerate over all objects in the receiver using aBlock.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumerate over all objects in the receiver with aBlock utilizing the options specified by opts.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) enumerateObjectsWithOptions: (NSEnumerationOptions)opts
|
|
|
|
usingBlock: (GSEnumeratorBlock)aBlock;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* First object in the receiver.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) firstObject;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Last object in the receiver.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) lastObject;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the object at index in the receiver.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the object at index in the receiver.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (GS_GENERIC_TYPE(ElementT)) objectAtIndexedSubscript: (NSUInteger)index;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns objects at the indexes specified in the receiver.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT)*) objectsAtIndexes: (NSIndexSet *)indexes;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of anObject in the receiver.
|
|
|
|
*/
|
|
|
|
- (NSUInteger) indexOfObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of object key, contained within range, using options, and the provided comparator.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (NSUInteger) indexOfObject: (id)key
|
2024-11-16 12:06:27 +00:00
|
|
|
inSortedRange: (NSRange)range
|
|
|
|
options: (NSBinarySearchingOptions)options
|
|
|
|
usingComparator: (NSComparator)comparator;
|
|
|
|
|
2024-11-17 17:04:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the index of objects at indexSet that pass the test in predicate with enumeration options opts.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (NSUInteger) indexOfObjectAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of the first object passing test predicate.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (NSUInteger) indexOfObjectPassingTest: (GSPredicateBlock)predicate;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of the first object passing test predicate using enumeration options opts.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (NSUInteger) indexOfObjectWithOptions: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSIndexSet containing indexes of object at indexes in indexSet matching predicate
|
|
|
|
* with enumeration options opts.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (NSIndexSet *) indexesOfObjectsAtIndexes: (NSIndexSet *)indexSet
|
|
|
|
options: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
|
|
|
|
2024-11-17 17:04:24 +00:00
|
|
|
/**
|
|
|
|
* Returns an NSIndexSet containing indexes that match predicate.
|
|
|
|
*/
|
|
|
|
- (NSIndexSet *) indexesOfObjectsPassingTest: (GSPredicateBlock)predicate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSIndexSet containing indexes that match predicate using opts.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (NSIndexSet *) indexesOfObjectsWithOptions: (NSEnumerationOptions)opts
|
|
|
|
passingTest: (GSPredicateBlock)predicate;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSEnumerator to iterate over each object in the receiver.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) objectEnumerator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSEnumerator to iterate over each object in the receiver in reverse order.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSOrderedSet that contains the same objects as the receiver, but in reverse order.
|
|
|
|
*/
|
2019-05-18 07:56:11 +00:00
|
|
|
- (NSOrderedSet *)reversedOrderedSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a C array of objects in aBuffer at indexes specified by aRange.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer
|
2024-11-16 12:06:27 +00:00
|
|
|
range: (NSRange)aRange;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// Key value coding support
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set value for key.
|
|
|
|
*/
|
2019-07-10 09:39:43 +00:00
|
|
|
- (void) setValue: (id)value forKey: (NSString*)key;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the value for a given key.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (id) valueForKey: (NSString*)key;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// Comparing Sets
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver is equal to aSet.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (BOOL) isEqualToOrderedSet: (NSOrderedSet *)aSet;
|
2024-11-16 12:06:27 +00:00
|
|
|
|
2019-05-16 17:53:15 +00:00
|
|
|
// Set operations
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver intersects with ordered set aSet.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (BOOL) intersectsOrderedSet: (NSOrderedSet *)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver intersects with set aSet.
|
|
|
|
*/
|
2019-05-27 11:40:18 +00:00
|
|
|
- (BOOL) intersectsSet: (NSSet *)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver is a subset of ordered set aSet.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (BOOL) isSubsetOfOrderedSet: (NSOrderedSet *)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns YES if the receiver is a subset of set aSet.
|
|
|
|
*/
|
2019-05-27 11:40:18 +00:00
|
|
|
- (BOOL) isSubsetOfSet:(NSSet *)aSet;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// Creating a Sorted Array
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSArray instance containing the elements from the receiver sorted using sortDescriptors.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingDescriptors: (NSArray *)sortDescriptors;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSArray instance containing the elements from the receiver sorted using comparator.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingComparator:
|
|
|
|
(NSComparator)comparator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSArray instance containing the elements from the receiver using options, sorted
|
|
|
|
* using comparator.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *)
|
|
|
|
sortedArrayWithOptions: (NSSortOptions)options
|
2024-11-16 12:06:27 +00:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// Filtering Ordered Sets
|
2024-11-17 17:04:24 +00:00
|
|
|
/**
|
|
|
|
* Returns an NSOrderedSet instance containing elements filtered using predicate.
|
|
|
|
*/
|
|
|
|
- (NSOrderedSet *) filteredOrderedSetUsingPredicate: (NSPredicate *)predicate;
|
2019-05-16 17:53:15 +00:00
|
|
|
|
|
|
|
// Describing a set
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Description of this NSOrderedSet.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (NSString *) description;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Localized description of this NSOrderedSet.
|
|
|
|
*/
|
2019-05-16 17:53:15 +00:00
|
|
|
- (NSString *) descriptionWithLocale: (NSLocale *)locale;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Localized description, indented if flag is YES.
|
|
|
|
*/
|
2019-05-20 08:01:20 +00:00
|
|
|
- (NSString *) descriptionWithLocale: (NSLocale *)locale indent: (BOOL)flag;
|
2019-06-08 02:39:51 +00:00
|
|
|
|
2024-11-17 17:04:24 +00:00
|
|
|
// Convert to other types
|
|
|
|
/**
|
|
|
|
* Returns an NSArray instance with the objects contained in the receiver.
|
|
|
|
*/
|
2022-02-14 09:23:46 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSArray, ElementT) *) array;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an NSSet instance with the objects contained in the receiver.
|
|
|
|
*/
|
2022-02-14 09:23:46 +00:00
|
|
|
- (GS_GENERIC_CLASS(NSSet, ElementT) *) set;
|
2019-05-16 17:53:15 +00:00
|
|
|
@end
|
2019-05-16 18:03:53 +00:00
|
|
|
|
|
|
|
// Mutable Ordered Set
|
2024-11-17 17:04:24 +00:00
|
|
|
/**
|
|
|
|
* This class provides a mutable ordered set.
|
|
|
|
*/
|
2021-01-18 13:20:14 +00:00
|
|
|
GS_EXPORT_CLASS
|
2019-07-09 15:19:22 +00:00
|
|
|
@interface GS_GENERIC_CLASS(NSMutableOrderedSet, ElementT) : GS_GENERIC_CLASS(NSOrderedSet, ElementT)
|
2019-05-18 00:17:10 +00:00
|
|
|
// Creating a Mutable Ordered Set
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an ordered set with capacity.
|
|
|
|
*/
|
|
|
|
+ (instancetype) orderedSetWithCapacity: (NSUInteger)capacity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes an ordered set with capacity.
|
|
|
|
*/
|
|
|
|
- (instancetype) initWithCapacity: (NSUInteger)capacity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes an empty ordered set.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (instancetype) init;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an object to the receiver.
|
|
|
|
*/
|
|
|
|
- (void) addObject: (GS_GENERIC_TYPE(ElementT))anObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds items in the C array whose length is indicated by count to the receiver.
|
|
|
|
*/
|
|
|
|
- (void) addObjects: (const GS_GENERIC_TYPE(ElementT)[])objects count: (NSUInteger)count;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds objects from otherArray to the receiver.
|
|
|
|
*/
|
|
|
|
- (void) addObjectsFromArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts object into the receiver at index.
|
|
|
|
*/
|
|
|
|
- (void) insertObject: (GS_GENERIC_TYPE(ElementT))object atIndex: (NSUInteger)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the object at index/
|
|
|
|
*/
|
|
|
|
- (void) setObject: (GS_GENERIC_TYPE(ElementT))object atIndexedSubscript: (NSUInteger)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts objects at indexes from array. The number of elements in indexes must be the same as the number of
|
|
|
|
* elements in array.
|
|
|
|
*/
|
|
|
|
- (void) insertObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)array atIndexes: (NSIndexSet *)indexes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove object from receiver.
|
|
|
|
*/
|
|
|
|
- (void) removeObject: (GS_GENERIC_TYPE(ElementT))object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove object at index.
|
|
|
|
*/
|
|
|
|
- (void) removeObjectAtIndex: (NSUInteger)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove objects at indexes.
|
|
|
|
*/
|
|
|
|
- (void) removeObjectsAtIndexes: (NSIndexSet *)indexes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove objects matching items in otherArray.
|
|
|
|
*/
|
|
|
|
- (void) removeObjectsInArray: (GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove objects at indexes matching range.
|
|
|
|
*/
|
|
|
|
- (void) removeObjectsInRange: (NSRange)range;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all objects from the set.
|
|
|
|
*/
|
|
|
|
- (void) removeAllObjects;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace the object at index with object.
|
|
|
|
*/
|
|
|
|
- (void) replaceObjectAtIndex: (NSUInteger)index
|
|
|
|
withObject: (GS_GENERIC_TYPE(ElementT))object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace objects at indexes with objects. The number of objects must correspond to the number of indexes.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes
|
2024-11-16 12:06:27 +00:00
|
|
|
withObjects: (GS_GENERIC_CLASS(NSArray, ElementT)*)objects;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace objects in the given range with items from the C array objects.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) replaceObjectsInRange: (NSRange)range
|
|
|
|
withObjects: (const GS_GENERIC_TYPE(ElementT)[])objects
|
|
|
|
count: (NSUInteger)count;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set object at index.
|
|
|
|
*/
|
|
|
|
- (void) setObject: (GS_GENERIC_TYPE(ElementT))object atIndex: (NSUInteger)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move objects at indexes to index.
|
|
|
|
*/
|
|
|
|
- (void) moveObjectsAtIndexes: (NSIndexSet *)indexes toIndex: (NSUInteger)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exchange object at index with object at otherIndex.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) exchangeObjectAtIndex: (NSUInteger)index withObjectAtIndex: (NSUInteger)otherIndex;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter objects using predicate.
|
|
|
|
*/
|
|
|
|
- (void) filterUsingPredicate: (NSPredicate *)predicate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort using descriptors.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) sortUsingDescriptors: (NSArray *)descriptors;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort using comparator
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (void) sortUsingComparator: (NSComparator)comparator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort with options and comparator.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (void) sortWithOptions: (NSSortOptions)options
|
2024-11-16 12:06:27 +00:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort the given range using options and comparator.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (void) sortRange: (NSRange)range
|
2024-11-16 12:06:27 +00:00
|
|
|
options: (NSSortOptions)options
|
2019-05-18 00:17:10 +00:00
|
|
|
usingComparator: (NSComparator)comparator;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method leaves only objects that interesect with ordered set aSet in the receiver.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) intersectOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method leaves only objects that intersect with set aSet in the receiver.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) intersectSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Receiver contains itself minus those elements in ordered set aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) minusOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Receiver contains itself minus those elements in aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) minusSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Receiver contains the union of itself and ordered set aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) unionOrderedSet: (GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Receiver contains the union of itself and aSet.
|
|
|
|
*/
|
2024-11-16 12:06:27 +00:00
|
|
|
- (void) unionSet: (GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
|
2024-11-17 17:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of NSCopying protocol.
|
|
|
|
*/
|
2019-05-18 00:17:10 +00:00
|
|
|
- (instancetype) initWithCoder: (NSCoder *)coder;
|
2019-05-16 18:03:53 +00:00
|
|
|
@end
|
2019-05-18 00:17:10 +00:00
|
|
|
|
2019-06-13 22:58:50 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
2019-05-18 00:17:10 +00:00
|
|
|
#endif
|
2019-06-13 22:58:50 +00:00
|
|
|
|
2019-06-27 06:00:14 +00:00
|
|
|
#endif /* OS_API_VERSION check */
|
|
|
|
|
2019-06-13 22:58:50 +00:00
|
|
|
#endif /* _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE */
|