"Learning Notes" "Foundation" set set

Source: Internet
Author: User

Immutable Collection Nsset

: The collection element is not sequential, there is no index number, and the element is not repeatable.

Nsset is functionally considered to be the parent set of Nsarray, which is a more general class.

Nsset contains the following common methods:

Setbyaddingobject:

Setbyaddingobjectfromarray:

Setbyaddingobjectfromset:

Allobject: Returns the Nsarray of all elements in the collection

Anyobject: Returns an element of the collection

Containsobject:

Member

Objectspassingtest:

Objectswithoptions:passingtest:

Issubsetofset:

Intersectsset:

Isequaltoset:

Nsset criteria for repeating the underlying judgment element:

1. Call the hash method of the element to obtain the Hashcode value of the object, determine whether it is equal, if equal, put in the same storage location, and continue to determine whether the isequal is the same;

2. Determine if the isequal is the same, and if it is different, store it in the same position in the hash table and form the chain. If the same, it is represented as the same element, and the addition fails.

Variable collection: Nsmuableset:

You can specify the initial capacity of the underlying hash table when you create the Nsmutableset collection:

nsmutableset* Set=[nsmutableset Setwithcapacity:10];

Added a method to delete elements, and can calculate the set, intersection, Difference set:

AddObject:

Removeobject:

Removeallobjects:

Addobjectsfromarray:

Unionset:

Minusset:

Intersectset:

Setset: Replaces elements in an existing collection with elements from the latter collection

Nscountedset:

Each time the same element is added, the element is added 1, and only the element is added at 0 o'clock, the element will be deleted;

Countforobject: Gets the number of times the specified element was added

Ordered collection: Nsorderedset,nsmutableorderedset

"Learning Notes" "Foundation" set set

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.