libs-base/Headers/Foundation/NSOrderedSet.h

210 lines
9.6 KiB
C
Raw Normal View History

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
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#ifndef _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
#define _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#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
@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
@interface GS_GENERIC_CLASS(NSOrderedSet, __covariant ElementT) : NSObject <NSCoding,
NSCopying,
NSMutableCopying,
NSFastEnumeration>
// class methods
+ (instancetype) orderedSet;
+ (instancetype) orderedSetWithArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)objects;
+ (instancetype) orderedSetWithArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)objects
range: (NSRange)range
copyItems:(BOOL)flag;
+ (instancetype) orderedSetWithObject:(GS_GENERIC_TYPE(ElementT))anObject;
+ (instancetype) orderedSetWithObjects:(GS_GENERIC_TYPE(ElementT))firstObject, ...;
+ (instancetype) orderedSetWithObjects:(const GS_GENERIC_TYPE(ElementT)[])objects
count:(NSUInteger) count;
2019-05-20 08:01:20 +00:00
+ (instancetype) orderedSetWithOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
2019-05-16 17:53:15 +00:00
+ (instancetype) orderedSetWithSet:(GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
+ (instancetype) orderedSetWithSet:(GS_GENERIC_CLASS(NSSet, ElementT)*)aSet
copyItems:(BOOL)flag;
// instance methods
2019-05-18 07:56:11 +00:00
- (instancetype) initWithArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)array;
- (instancetype) initWithArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)array copyItems:(BOOL)flag;
- (instancetype) initWithArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)array
2019-05-16 17:53:15 +00:00
range:(NSRange)range
copyItems:(BOOL)flag;
2019-05-18 07:56:11 +00:00
- (instancetype) initWithObject:(id)object;
2019-05-16 17:53:15 +00:00
- (instancetype) initWithObjects:(GS_GENERIC_TYPE(ElementT))firstObject, ...;
- (instancetype) initWithObjects:(const GS_GENERIC_TYPE(ElementT)[])objects
count:(NSUInteger)count;
2019-05-20 08:01:20 +00:00
- (instancetype) initWithOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
- (instancetype) initWithOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
2019-05-18 00:17:10 +00:00
copyItems:(BOOL)flag;
2019-05-20 08:01:20 +00:00
- (instancetype) initWithOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet
2019-05-16 17:53:15 +00:00
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-18 00:17:10 +00:00
- (instancetype) init;
2019-05-16 17:53:15 +00:00
- (NSUInteger) count;
- (BOOL)containsObject:(GS_GENERIC_TYPE(ElementT))anObject;
2019-05-18 00:17:10 +00:00
- (void) enumerateObjectsAtIndexes:(NSIndexSet *)indexSet
2019-05-16 17:53:15 +00:00
options:(NSEnumerationOptions)opts
usingBlock:(GSEnumeratorBlock)aBlock;
- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock;
- (void) enumerateObjectsWithOptions:(NSEnumerationOptions)opts
usingBlock:(GSEnumeratorBlock)aBlock;
- (GS_GENERIC_TYPE(ElementT)) firstObject;
- (GS_GENERIC_TYPE(ElementT)) lastObject;
- (GS_GENERIC_TYPE(ElementT)) objectAtIndex: (NSUInteger)index;
2019-05-18 00:17:10 +00: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 17:53:15 +00:00
- (NSUInteger) indexOfObject: (id)key
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
2019-05-16 17:53:15 +00:00
passingTest:(GSPredicateBlock)predicate;
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) objectEnumerator;
- (GS_GENERIC_CLASS(NSEnumerator, ElementT)*) reverseObjectEnumerator;
2019-05-18 07:56:11 +00:00
- (NSOrderedSet *)reversedOrderedSet;
2019-05-16 17:53:15 +00:00
- (void) getObjects: (__unsafe_unretained GS_GENERIC_TYPE(ElementT)[])aBuffer
range: (NSRange)aRange;
// Key value coding support
- (void) setValue: (GS_GENERIC_TYPE(ElementT))value forKey: (NSString*)key;
- (GS_GENERIC_TYPE(ElementT)) valueForKey: (NSString*)key;
// Comparing Sets
- (BOOL) isEqualToOrderedSet: (NSOrderedSet *)aSet;
// Set operations
- (BOOL) intersectsOrderedSet: (NSOrderedSet *)aSet;
2019-05-27 11:40:18 +00:00
- (BOOL) intersectsSet: (NSSet *)aSet;
2019-05-16 17:53:15 +00:00
- (BOOL) isSubsetOfOrderedSet: (NSOrderedSet *)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
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingDescriptors:(NSArray *)sortDescriptors;
- (GS_GENERIC_CLASS(NSArray, ElementT) *) sortedArrayUsingComparator:
(NSComparator)comparator;
- (GS_GENERIC_CLASS(NSArray, ElementT) *)
sortedArrayWithOptions: (NSSortOptions)options
usingComparator: (NSComparator)comparator;
// Filtering Ordered Sets
- (NSOrderedSet *)filteredOrderedSetUsingPredicate: (NSPredicate *)predicate;
// Describing a set
- (NSString *) description;
- (NSString *) descriptionWithLocale: (NSLocale *)locale;
2019-05-20 08:01:20 +00:00
- (NSString *) descriptionWithLocale: (NSLocale *)locale indent: (BOOL)flag;
// Convert to other types
- (NSArray *) array;
- (NSSet *) set;
2019-05-16 17:53:15 +00:00
@end
// Mutable Ordered Set
@interface GS_GENERIC_CLASS(NSMutableOrderedSet, __covariant ElementT) : NSOrderedSet
2019-05-18 00:17:10 +00:00
// Creating a Mutable Ordered Set
+ (instancetype)orderedSetWithCapacity: (NSUInteger)capacity;
- (instancetype)initWithCapacity: (NSUInteger)capacity;
- (instancetype) init;
- (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;
2019-05-18 00:17:10 +00:00
- (void)removeObjectsAtIndexes:(NSIndexSet *)indexes;
- (void)removeObjectsInArray:(GS_GENERIC_CLASS(NSArray, ElementT)*)otherArray;
2019-05-28 09:40:22 +00:00
- (void)removeObjectsInRange:(NSRange)range;
2019-05-18 00:17:10 +00:00
- (void)removeAllObjects;
- (void)replaceObjectAtIndex:(NSUInteger)index
withObject:(GS_GENERIC_TYPE(ElementT))object;
- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes
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;
- (void) sortUsingComparator: (NSComparator)comparator;
- (void) sortWithOptions: (NSSortOptions)options
usingComparator: (NSComparator)comparator;
- (void) sortRange: (NSRange)range
options:(NSSortOptions)options
usingComparator: (NSComparator)comparator;
- (void) intersectOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
2019-05-20 08:01:20 +00:00
- (void) intersectSet:(GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
2019-05-18 00:17:10 +00:00
- (void) minusOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
2019-05-20 08:01:20 +00:00
- (void) minusSet:(GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
2019-05-18 00:17:10 +00:00
- (void) unionOrderedSet:(GS_GENERIC_CLASS(NSOrderedSet, ElementT)*)aSet;
2019-05-20 08:01:20 +00:00
- (void) unionSet:(GS_GENERIC_CLASS(NSSet, ElementT)*)aSet;
2019-05-18 00:17:10 +00:00
- (instancetype) initWithCoder: (NSCoder *)coder;
@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
#endif /* _NSOrderedSet_h_GNUSTEP_BASE_INCLUDE */