当前位置:网站首页>OC - NSSet (set)
OC - NSSet (set)
2022-08-02 07:48:00 【Peng classmate her deskmate】
The difference from Array
The way of storage in memory is discontinuous
It is more efficient when searching for elements because hash is used. For example, to find an element set, it can be found directly through the hash algorithm.And Array needs to be traversed
to find the intersection and union
NSSet
Initialization
NSSet*set = [[NSSet alloc]initWithObjects:@"a",@"b",nil];NSSet*set2 = [set2 setWithArray]
Check
if([set containsObject:@"a"])NSLog(@"YES");
Intersection
//set(a,b,c).set2(a,s,d,)if([set intersectsSet:set2])NSLog(@"YES");//Seek if there are the same elements[set intersectSet:set2];NSLog(@"%@",set);//a
Union
//set(a,b,c).set2(a,s,d,)
[set unionSet:set2];//The common ones in set2 and se1 will be added to the set.re
NSLog(@“%@”,set);//a,b,c,s,d
Seek complement
//set(a,b,c).set2(a,s,d,)
[set minusSet:set2];
NSLog(@“%@”,set);//b,c
NSMutableSet
NSMutableSet*mset = [[NSMutableSet alloc]initWithCapacity:0];[set addObject:@"a"];
边栏推荐
猜你喜欢
随机推荐
【ROS基础】rosbag 的使用方法
(2022牛客多校五)D-Birds in the tree(树形DP)
【网络】IP、子网掩码
yml字符串读取时转成数字了怎么解决
逆变器绝缘检测检测功能及软件实现
(2022牛客多校五)C-Bit Transmission(思维)
MQ带来的一些问题、及解决方案
新产品立大功 伟世通第二季度营收双增
海缆探测仪TSS350(二)
(2022牛客多校五)B-Watches(二分)
docker 安装mysql
“蔚来杯“2022牛客暑期多校训练营5,签到题KBGHFCD
Submit code process
有趣的网站
吃透Chisel语言.30.Chisel进阶之通信状态机(二)——FSMD:以Popcount为例
数据库概论之MySQL表的增删改查1
HCIP day one
问个问题,我的Flinkcdc已经跑通了,可以监听msql的binlog了,也能发送kafk
Splunk Field Caculated 计算字段
【图像去噪】基于matlab双立方插值和稀疏表示图像去噪【含Matlab源码 2009期】