当前位置:网站首页>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"];
边栏推荐
猜你喜欢
[21天学习挑战赛——内核笔记](一)——设备树的概述(硬件、目标、效果、文件类型)
[Dataset][VOC] Male and female dataset voc format 6188 sheets
数据库概论之MySQL表的增删改查1
File upload vulnerability (2)
Splunk Field Caculated 计算字段
Xilinx约束学习笔记—— 时序约束
Splunk Filed extraction 字段截取
实例032:反向输出II
HCIP day one
Vscode connect to remote server "Acquiring the lock on the/home / ~ 'problem
随机推荐
【图像隐藏】基于matlab混合DWT-HD-SVD数字图像水印方法技术【含Matlab源码 2007期】
59:第五章:开发admin管理服务:12:MongoDB的使用场景;(非核心数据,数据量比较大的非核心数据,人脸照片等隐私的小文件;)
MySQL-FlinkCDC-Hudi实时入湖
File upload vulnerability (2)
交换网络----三种生成树协议
Day 4 of HCIP
逆变器绝缘检测检测功能及软件实现
【杂】pip换国内源教程及国内源地址
解决:- SPY: No data found for this date range, symbol may be delisted报错
交换--STP协议
数据库概论之MySQL表的增删改查1
SimpleChannelInboundHandler使用总结
Splunk Filed Alias 字段改名
海缆探测仪TSS350(二)
查看僵尸进程
论文《Deep Multifaceted Transformers for Multi-objective Ranking in Large-Scale E-commerce Recommender》
【暑期每日一题】洛谷 P1255 数楼梯
Go 实现分布式锁
图腾柱和推挽电路介绍
See the picture to understand | How to choose sales indicators to measure the health of business growth