zoukankan      html  css  js  c++  java
  • 可变集合 NSMutableSet

    //创建指定元素个数的一个集合对象

            NSMutableSet *set = [NSMutableSet setWithCapacity:10];

            

    //添加一个对象到集合

            [set addObject:@"adsf"];

            NSLog(@"%@", set);

            

    //从集合中删除一个对象

            [set removeObject:@"adsf"];

            NSLog(@"%@", set);

            

    //把数组对象添加到集合对象中去

            NSArray *array = [[NSArray alloc]initWithObjects:@"125"@"qew"@"sd526fs"nil];

            [set addObjectsFromArray:array];

            NSLog(@"%@", set);

            

    //得交两个集合的交集

            NSMutableSet *set1 = [NSMutableSet setWithObjects:@"123"@"456"@"789"nil];

            NSMutableSet *set2 = [NSMutableSet setWithObjects:@"123"@"456"@"987"nil];

            //[set1 intersectSet:set2];  //得到的交集把set1的值替代,set2值不变

            NSLog(@"%@", set1);

    //从一个集合中减去另一个交集,就是求前一个集合和后一个集合的不同元素值

            NSMutableSet *set3 = [[NSMutableSet allocinitWithObjects:set1, nil];

           [set3 addObject:set2];

    //一个集合减去另一个集合

           [set3 minusSet:[NSMutableSet setWithObjects:set2, nil]];

    NSLog(@"%@", set3);

  • 相关阅读:
    报名用户主题看板
    有效线索主题看板 阿善有用 清洗转换具体怎么做
    意向客户主题看板 阿善看到 阿善用到 拉链表
    数据库建模 全量表导入
    git 阿善有用
    IDEA+git+码云
    Cloudera Manager的基本使用 阿善没用
    cloudera manager报错解决方案
    java-多态简述及实例
    java-简述接口及实例
  • 原文地址:https://www.cnblogs.com/Azazqing/p/3696586.html
Copyright © 2011-2022 走看看