zl程序教程

您现在的位置是:首页 >  前端

当前栏目

去重算法-hash-set

set算法 HASH
2023-09-11 14:18:45 时间

Well, as Bavarious pointed out in a comment, Apple's actual CoreFoundation source is open and available for your perusal too. NSSet is implemented on top of CFSet, whose code is generated (as is that of CFDictionary) from a hash table template, using CFBasicHash to do the work. 

The difference between mutablility and immutability seems to be the matter of a flag in the structure (line 91 of CFBasicHash.h), and from my reading so far just affects calls to functions such as CFBasicHashAddValue; there's a simple check for the mutability. It seems likely, however, that Cobbal is right about the copy/retain behavior between the two (I just haven't read that far yet).

 

保证数据的唯一性。

 

https://stackoverflow.com/questions/5863510/nsset-implementation