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);

  • 相关阅读:
    POJ 2486 Apple Tree(树形DP)
    HDOJ 4276 鬼吹灯 (树形DP)
    POJ 2923 Relocation(状态压缩DP)
    Vue,事件的修饰符
    Vye,v-if 和 v-show 显示隐藏的使用
    Vue,for循环的key值绑定
    Vue,v-for循环遍历方式
    Vue-class样式,style样式
    Vue,v-model双向事件绑定 及简易计算器练习
    uni-app 生命周期(下拉已解决)
  • 原文地址:https://www.cnblogs.com/Azazqing/p/3696586.html
Copyright © 2011-2022 走看看