Objective-C set object (nsset and nsmutableset)

Source: Internet
Author: User
Tags new set

A collection (nsset) object is a combination of Single-value objects. For example, a set of 1 to 50 numbers.

Operations on collection objects include searching, adding, and deleting members in a set, comparing two sets, and calculating the intersection and union of the two sets.

Common nsset methods:

+ (ID) setwithobjects: obj1, obj2, obj3 ,... nil // use a group of objects to create a new set-(ID) initwithobjects: obj1, obj2 ,... nil // use a group of objects to initialize the newly assigned set-(nsuinterger) Count // return the number of members of the Set-(bool) containsobject: OBJ // determine whether the set contains the object obj-(bool) Member: OBJ // determine whether the set contains the object obj-(nsenumerator *) objectenumerator // return all objects in the set to an nseumerator type object-(bool) issubsetofset: nsset // determine whether it is a subset of the nsset-(bool) intersectsset: nsset // determine whether there is at least one element in the intersection of the two sets // or: Determine whether there is at least one element in the collection in nsset-(BOO) isw.toset: nsset // determine whether two sets are equal

Common nsmutableset methods:

-(ID) setwithcapacity: Size-(ID) initwithcapacity: Size-(void) addobject: OBJ // Add an object to the Set-(void) removeobject: OBJ // Delete object obj-(void) removeallobjects from the set // delete all objects in the Set-(void) unionset: nsset // Add all elements of nsset to the set, that is, the Union set-(void) minusset: nsset // removes all nsset elements from the set-(void) interectset: nsset // sets and nsset for intersection operations, that is, intersection
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.