NSSet, NSMutableSet, and NSCountedSet classes declare an unordered set of programming interface objects (hashed storage: The storage location in the memory is not continuous ).
The NSArray and NSDictionary classes declare an ordered set of programming interface objects (ordered storage: sequential storage in memory ).
NSSet and NSMutableSet are the same as NSArray and NSMutableArray. NSSet declares static objects. When an NSSet object is created, the subsequent climate entries cannot be modified. The NSMutableSet object can be dynamically added or deleted, and the memory is automatically allocated according to the object length.
Note that only cocoa objects can be added to NSSet and NSArray. To add basic data types (int, float, BOOL, double, etc.), encapsulate the data into NSNumber.
NSSet is not much different from NSArray in actual application, but if you want to find an element in NSArray, You need to traverse the entire array, which is inefficient. NSSet directly finds the position of a specific element based on the hash algorithm, which is highly efficient.
NSSet
-(NSArray *) allObjects;
-(Id) anyObject;
-(BOOL) containsObject :( id) anObject;
-(NSString *) description;
-(NSString *) descriptionWithLocale :( id) locale;
-(BOOL) intersectsSet :( NSSet *) otherSet;
-(BOOL) isEqualToSet :( NSSet *) otherSet;
-(BOOL) isSubsetOfSet :( NSSet *) otherSet;
+ (Id) set;
+ (Id) setWithObject :( id) object;
+ (Id) setWithObjects :( const
Id *) objects count :( NSUInteger) cnt;
+ (Id) setWithObjects :( id) firstObj ,...
NS_REQUIRES_NIL_TERMINATION;
+ (Id) setWithSet :( NSSet *) set;
+ (Id) setWithArray :( NSArray *) array;
-(Id) initWithObjects :( const
Id *) objects count :( NSUInteger) cnt;
-(Id) initWithObjects :( id) firstObj ,...
NS_REQUIRES_NIL_TERMINATION;
-(Id) initWithSet :( NSSet *) set;
-(Id) initWithSet :( NSSet *) set copyItems :( BOOL) flag;
-(Id) initWithArray :( NSArray *) array;
NSMutableSet (NSExtendedMutableSet)
-(Void) addObjectsFromArray :( NSArray *) array;
-(Void) intersectSet :( NSSet *) otherSet;
-(Void) minusSet :( NSSet *) otherSet;
-(Void) removeAllObjects;
-(Void) unionset :( nsset *) otherset;
-(Void) setset :( nsset *) otherset;
+ (ID) setwithcapacity :( nsuinteger) numitems;
-(ID) initwithcapacity :( nsuinteger) numitems;