当前位置:网站首页>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);//aUnion
//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"];边栏推荐
猜你喜欢
随机推荐
根据一个字段的内容去更新另一个字段的数据,这样的sql语句该怎么样书写
MQ带来的一些问题、及解决方案
Gradle系列——Gradle插件(基于Gradle文档7.5)day3-2
聊天机器人如何提升独立站的营销水平?
张驰课堂:六西格玛培训工具——箱线图
电商库存系统的防超卖和高并发扣减方案
论文《Deep Multifaceted Transformers for Multi-objective Ranking in Large-Scale E-commerce Recommender》
OC-范畴
修改apt-get源为国内镜像源
倍福使用AdsRemote组件实现和C#的ADS通讯
查看端口号占用
【ROS基础】rosbag 的使用方法
解决Pytorch模型在Gunicorn部署无法运行或者超时问题
Vscode connect to remote server "Acquiring the lock on the/home / ~ 'problem
Day 4 of HCIP
C# FileInfo class
59:第五章:开发admin管理服务:12:MongoDB的使用场景;(非核心数据,数据量比较大的非核心数据,人脸照片等隐私的小文件;)
(2022牛客多校五)B-Watches(二分)
【云原生】如何快速部署Kubernetes
【网络】IP、子网掩码









