当前位置:网站首页>OC-NSSet(集合)
OC-NSSet(集合)
2022-08-02 06:50:00 【彭同学她同桌】
与Array的区别
在内存中存储的方式是不连续的
在搜索一个个元素的时候效率更高 因为使用的是hash 比如说找一个元素 set通过hash算法可以直接找到 而Array就需要通过遍历
可以求交集并集
NSSet
初始化
NSSet*set = [[NSSet alloc]initWithObjects:@"a",@"b",nil];
NSSet*set2 = [set2 setWithArray]
查
if([set containsObject:@"a"])NSLog(@"YES");
求交集
//set(a,b,c). set2(a,s,d,)
if([set intersectsSet:set2])NSLog(@"YES");//求是否有相同元素
[set intersectSet:set2];
NSLog(@"%@",set);//a
求并集
//set(a,b,c). set2(a,s,d,)
[set unionSet:set2];//会将set2和se1中共同的都加到set中 会去重
NSLog(@“%@”,set);//a,b,c,s,d
求补集
//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"];
边栏推荐
- (2022牛客多校五)B-Watches(二分)
- [Dataset][VOC] Male and female dataset voc format 6188 sheets
- July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
- 论文《Deep Multifaceted Transformers for Multi-objective Ranking in Large-Scale E-commerce Recommender》
- 【心电信号】基于matlab心率检测【含Matlab源码 1993期】
- gdalinfo: error while loading shared libraries: libgdal.so.30: cannot open shared object file: No su
- The nacos source code can not find the istio package
- (Notes are not completed) [Graph Theory] Traversal of graphs
- 【暑期每日一题】洛谷 P1255 数楼梯
- FaceBook社媒营销高效转化技巧分享
猜你喜欢
随机推荐
【机器学习】课程设计布置:某闯关类手游用户流失预测
System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security
实例026:递归求阶乘
[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir
【ROS基础】rosbag 的使用方法
主流定时任务解决方案全横评
Connection reset by peer problem analysis
【故障诊断分析】基于matlab FFT轴承故障诊断(包络谱)【含Matlab源码 2002期】
【CV】OpenVINO安装教程
【机器学习】实验4布置:AAAI会议论文聚类分析
电商库存系统的防超卖和高并发扣减方案
逆变器锁相原理及DSP实现
速看!PMP新考纲、PMBOK第七版解读
【论文精读】Geometric Structure Preserving Warp for Natural Image Stitching
每周推荐短视频:为什么产品开发需要数字化?如何做到数字化?
MQ带来的一些问题、及解决方案
Vscode connect to remote server "Acquiring the lock on the/home / ~ 'problem
交换网络----三种生成树协议
(部分不懂,笔记整理未完成)【图论】差分约束
At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died








![[Dataset][VOC] Eyewear dataset 6000 in VOC format](/img/66/37f76d9ce5d5f68d6ea0e18710fa04.png)
