/* NSSet.h Copyright (c) 1994-2019, Apple Inc. All rights reserved. */ #import #import @class NSArray, NSDictionary, NSString; /**************** Immutable Set ****************/ NS_HEADER_AUDIT_BEGIN(nullability, sendability) @interface NSSet<__covariant ObjectType> : NSObject @property (readonly) NSUInteger count; - (nullable ObjectType)member:(ObjectType)object; - (NSEnumerator *)objectEnumerator; - (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)initWithObjects:(const ObjectType _Nonnull [_Nullable])objects count:(NSUInteger)cnt NS_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; @end @interface NSSet (NSExtendedSet) @property (readonly, copy) NSArray *allObjects; - (nullable ObjectType)anyObject; - (BOOL)containsObject:(ObjectType)anObject; @property (readonly, copy) NSString *description; - (NSString *)descriptionWithLocale:(nullable id)locale; - (BOOL)intersectsSet:(NSSet *)otherSet; - (BOOL)isEqualToSet:(NSSet *)otherSet; - (BOOL)isSubsetOfSet:(NSSet *)otherSet; - (void)makeObjectsPerformSelector:(SEL)aSelector NS_SWIFT_UNAVAILABLE("Use enumerateObjectsUsingBlock: or a for loop instead"); - (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(nullable id)argument NS_SWIFT_UNAVAILABLE("Use enumerateObjectsUsingBlock: or a for loop instead"); - (NSSet *)setByAddingObject:(ObjectType)anObject API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); - (NSSet *)setByAddingObjectsFromSet:(NSSet *)other API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); - (NSSet *)setByAddingObjectsFromArray:(NSArray *)other API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); - (void)enumerateObjectsUsingBlock:(void (NS_NOESCAPE ^)(ObjectType obj, BOOL *stop))block API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)); - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(ObjectType obj, BOOL *stop))block API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)); - (NSSet *)objectsPassingTest:(BOOL (NS_NOESCAPE ^)(ObjectType obj, BOOL *stop))predicate API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)); - (NSSet *)objectsWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (NS_NOESCAPE ^)(ObjectType obj, BOOL *stop))predicate API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0)); @end @interface NSSet (NSSetCreation) + (instancetype)set; + (instancetype)setWithObject:(ObjectType)object; + (instancetype)setWithObjects:(const ObjectType _Nonnull [_Nonnull])objects count:(NSUInteger)cnt; + (instancetype)setWithObjects:(ObjectType)firstObj, ... NS_REQUIRES_NIL_TERMINATION; + (instancetype)setWithSet:(NSSet *)set; + (instancetype)setWithArray:(NSArray *)array; - (instancetype)initWithObjects:(ObjectType)firstObj, ... NS_REQUIRES_NIL_TERMINATION; - (instancetype)initWithSet:(NSSet *)set; - (instancetype)initWithSet:(NSSet *)set copyItems:(BOOL)flag; - (instancetype)initWithArray:(NSArray *)array; @end /**************** Mutable Set ****************/ @interface NSMutableSet : NSSet - (void)addObject:(ObjectType)object; - (void)removeObject:(ObjectType)object; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)initWithCapacity:(NSUInteger)numItems NS_DESIGNATED_INITIALIZER; @end @interface NSMutableSet (NSExtendedMutableSet) - (void)addObjectsFromArray:(NSArray *)array; - (void)intersectSet:(NSSet *)otherSet; - (void)minusSet:(NSSet *)otherSet; - (void)removeAllObjects; - (void)unionSet:(NSSet *)otherSet; - (void)setSet:(NSSet *)otherSet; @end @interface NSMutableSet (NSMutableSetCreation) + (instancetype)setWithCapacity:(NSUInteger)numItems; @end /**************** Counted Set ****************/ @interface NSCountedSet : NSMutableSet - (instancetype)initWithCapacity:(NSUInteger)numItems NS_DESIGNATED_INITIALIZER; - (instancetype)initWithArray:(NSArray *)array; - (instancetype)initWithSet:(NSSet *)set; - (NSUInteger)countForObject:(ObjectType)object; - (NSEnumerator *)objectEnumerator; - (void)addObject:(ObjectType)object; - (void)removeObject:(ObjectType)object; @end NS_HEADER_AUDIT_END(nullability, sendability)