集合对象(NSSet)
main.m
#import <Foundation/Foundation.h>
@interface NSSet(printInteger)
-(void)printSet; @end
@implementation NSSet(printInteger) -(void)printSet
{
for (NSNumber *integer in self) {
printf("%i",[integer integerValue]);
}
printf("\n");
} @end int main(void)
{
@autoreleasepool {
NSMutableSet *set1=[NSMutableSet setWithObjects:[NSNumber numberWithInteger:],
[NSNumber numberWithInteger:],
[NSNumber numberWithInteger:], nil];
NSMutableSet *set2=[NSMutableSet setWithObjects:[NSNumber numberWithInteger:],
[NSNumber numberWithInteger:],
[NSNumber numberWithInteger:], nil];
if ([set1 isEqualToSet:set2]==YES) {
NSLog(@"set1=set2");
}else{
NSLog(@"set1!=set2");
}
if ([set1 containsObject:[NSNumber numberWithInteger:]]==YES) {
NSLog(@"set1 included 3");
}else{
NSLog(@"set1 not included 3");
} [set1 printSet];
[set1 addObject:[NSNumber numberWithInteger:]];
[set1 removeObject:[NSNumber numberWithInteger:]];
[set1 printSet];
[set1 intersectSet:set2];
[set1 printSet]; [set1 intersectSet:set2];
[set1 printSet];
[set1 unionSet:set2];
[set1 printSet];
}
return ;
}
集合对象(NSSet)的更多相关文章
- 集合对象(NSSet,NSMutableSet,NSIndexSet)
NSArray:有序的集合,NSSet:无序的集合,散列存储. 但是NSSet保证数据的唯一性.当插入相同的数据时,不会有任何效果.从内部实现来说是hash表.NSMutableSet是NSSet的子 ...
- Objective-c 集合对象
集合(NSSet)是一组单值对象的组合,集合对象的操作包括:搜索,添加,删除集合中的成员(可变集合的功能),比较两个集合,计算两个集合的交集,并集等. 下面来看下(NSSet)的方法: 1)集合的构建 ...
- Asp.net MVC中提交集合对象,实现Model绑定
Asp.net MVC中的Model自动绑定功能,方便了我们对于request中的数据的处理, 从客户端的请求数据,自动地以Action方法参数的形式呈现.有时候我们的Action方法中想要接收数组类 ...
- Set集合对象比较两个元素的方法
Set集合对象比较两个元素的方法并不是根据“equals()”方法的返回值来比较.而是用“hashCode()”方法来进行判断.只要两个元素的“hashCode()”方法的返回值相同,就认为两个元素相 ...
- 转载---Java集合对象的深度复制与普通复制
原博文:http://blog.csdn.net/qq_29329775/article/details/49516247 最近在做算法作业时出现了错误,原因是没有弄清楚java集合的深度复制和浅度复 ...
- Objective-C之集合对象的内存管理
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- Asp.net MVC中提交集合对象,实现Model绑定(转载)
Asp.net MVC中的Model自动绑定功能,方便了我们对于request中的数据的处理, 从客户端的请求数据,自动地以Action方法参数的形式呈现.有时候我们的Action方法中想要接收数组类 ...
- JSon_零基础_004_将Set集合对象转换为JSon格式的对象字符串,返回给界面
将Set集合对象转换为JSon格式的对象字符串,返回给界面 需要导入的jar包: 编写:servlet: package com.west.webcourse.servlet; import java ...
- JSon_零基础_003_将Map集合对象转换为JSon格式的对象字符串,返回给界面
将Map集合对象转换为JSon格式的对象字符串,返回给界面 需导入的jar包: 编写servlet: package com.west.webcourse.servlet; import java.i ...
- java中对集合对象list的几种循环访问
java中对集合对象list的几种循环访问的总结如下 1 经典的for循环 public static void main(String[] args) { List<String> li ...
随机推荐
- CDN的原理及对SEO的影响
http://www.williamlong.info/archives/4059.html CDN的概念最早于1995年由美国麻省理工大学提出,是一套能够实现用户就近访问的网络解决方案.具体方法是: ...
- someExperience
// 面试题1 var name = 'World'; (function () { if (typeof name==='undefined') { var name = 'jack'; conso ...
- Ajax的概述与实现过程
一.ajax概述 1.Ajax是Asynchronous([ə'sɪŋkrənəs) JavaScript XML的简写,不是一门新技术,而是对现有技术的综合利用.这一技术能够向服务器请求额外数据而无 ...
- Menu bar missing from ClearCase Explorer
See following links: Menu bar missing from ClearCase Explorer Understanding the Rational ClearCase E ...
- [技术翻译] 构建现代化的Objective-C (下)
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3563880.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- Poj 1017 / OpenJudge 1017 Packets/装箱问题
1.链接地址: http://poj.org/problem?id=1017 http://bailian.openjudge.cn/practice/1017 2.题目: 总时间限制: 1000ms ...
- Linux网络应用编程之VLAN(Packet Tracer仿真)
VLAN 一.VLAN概述 VLAN(虚拟局域网):将多个设备和用户在逻辑上联网在一起,这些设备和用户不受物理位置的限制(物理设备可以在不同的地方),但是他们的通信就好像在同一网段中一样,这就叫VLA ...
- C#使用oledb方式将excel数据导入到datagridview后数据被截断为 255 个字符
问题描述:在使用oledb方式将excel数据导入到datagridview中,在datagridview单元格中的数据没有显示全,似乎只截取了数据源中的一段 解决方案:1.关于该问题,微软官方答案: ...
- JDK和Jython安装
下载JAVA SE,下载地址请到oracle官方网站下载. JDK下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8- ...
- opengl雾开启
#include <GL/glut.h> #include <stdio.h> #include <iostream> using namespace std; s ...