当前位置:网站首页>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"];边栏推荐
猜你喜欢
随机推荐
【心电信号】基于matlab心率检测【含Matlab源码 1993期】
实例032:反向输出II
敏捷、DevOps和嵌入式系统测试
(Part of it is not understood, and the notes are not completed) [Graph Theory] Difference Constraints
C# FileInfo class
论文阅读 (64):Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning
查看端口号占用
yml字符串读取时转成数字了怎么解决
_2_顺序表
CSRF-跨站请求伪造-相关知识
在VMware上安装Metasploitable2
入门opencv,欢笑快乐每一天
使用hutool做本地缓存的工具类
线程的创建方式
【网络】IP、子网掩码
获取间隔的日期列表工具类
LeetCode SQL 197. 上升的温度
堡垒机、堡垒机的原理
Resolving C# non-static field, method or property "islandnum.Program.getIslandCount(int[][], int, int)" requires an object reference
吃透Chisel语言.30.Chisel进阶之通信状态机(二)——FSMD:以Popcount为例









