去重算法-hash-set

本文深入探讨了NSSet在Apple Core Foundations框架中的实现细节。NSSet基于CFSet构建,而CFSet使用CFBasicHash进行工作,通过哈希表模板生成代码。文章讨论了可变性和不可变性的区别,主要体现在结构体中的一个标志位,以及对CFBasicHashAddValue等函数调用的影响。此外,还提到了Cobbal关于两种类型在copy/retain行为上的观点。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值