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