- 数据结构与算法(十一) 排序算法一
ぃ扶摇ぅ
排序算法算法数据结构
intnArray[]={8,5,3,2,7};如下一个数组,现对其进行从小到大排序选择排序选择排序:将小的依次放在前面具象化如下:voidswap(int*nSValue,int*nDValue)交换函数{intnTempValue=0;nTempValue=*nSValue;*nSValue=*nDValue;*nDValue=nTempValue;}voidselectSort(int*pA
- 怎样使用performSelector传入3个以上参数,其中一个为结构体。
natewang
多参数可组装为字典。结构体可封装为NSValue进行传递。NSValue*value=[NSValuevalueWithBytes:&testSobjCType:@encode(testStrout)];
- 4.3 KVC/KVO —— KVC的实现原理,如何避免产生崩溃
哈库呐玛塔塔__
?xmlversion="1.0"encoding="UTF-8"?KVC中最常见的异常就是不小心使用了错误的Key,或者在设值中不小心传递了nil的值因为KVC传递进去的值和取出来的值都是id类型,取值时KVC为结构体和变量类型是值类型的都会被封装为NSNumber或者NSValue返回回来,但是设置值的时候就需要自己去做这个转换了,也就是说开发者需要自己担保类型的正确性,运行时OC会在发送消息
- 03--KVC/KVO本质04--KVC 注意事项
修_远
总结KVC使用的一些注意事项KVC注意事项KVC自动转换类型使用string存基本类型,系统会存为__NSCFNumber[personsetValue:@"20"forKey:@"age"];结构体类型的值,系统会存为NSConcreteValue设置空值重写setNilValueForKey方法给NSNumber和NSValue类型的属性设置空值时,会走上面的方法其他类型不走这个方法找不到的k
- Block、Protocol、结构体、NSString、NSArray、NSFileManager、NSSet、NSDictionary、NSNumber、NSDate、NSValue
Andy_Livings
收集Block、Protocol、结构体、NSString、NSArray、NSFileManager、NSSet、NSDictionary、NSNumber、NSDate、NSValue等的基本用法。Blockblock要掌握的东西1>如何定义block变量int(^sumBlock)(int,int);void(^myBlock)();2>如何利用block封装代码^(inta,intb){r
- iOS Socket练习
我不白先生
1.创建两个工程一个是服务器一个是客户端2.在服务器端写好服务器接收数据的代码(监听端口和实现接收数据的方法)3.在客户端运行起来时和服务器建立连接4.在客户端点击屏幕的时候得到用户触摸屏幕的CGPoint把CGPoint转成NSValue再通过归档把NSValue转成NSData发给对方5.在服务器端接收到数据的时候把NSData解档转成NSValue在转回CGPoint在此位置创建Mouse对
- 1.6 ios NSNumber详解
草根小强
NSArray、NSDictionary、NSSet等集合对象只能保存对象,如果要保存char、short、int、float、double、BOOL或指向结构的指针等基础数据类型,则可以先将这些基本数据类型封装成NSNumber对象,再存入集合对象。NSNumber类用来包装基本数据类型。NSValue是NSNumber的父类。不能直接用NSNumber对象做计算,只能提取值。一般用法://包装
- Masonry 高度约束的三种方法
shareMind
UIView高度约束的三种方法(这里只是讨论equalTo(),这个block执行的结果)make.height.equalTo(@20);(@20可认为是一个NSValue代表)make.height.equalTo(self.view);make.height.equalTo(self.view.mas_height);执行equalTo()block,会有以下函数调用针对self.secon
- 利用递归解决服务器返回的null对象的问题
久远的回忆
1.解析后获得的字典调用此方法,会返回一个新的处理好的字典2.新的字典里所有的null对象被替换为@""3.也可以在此方法中做别的处理(比如说把NSValue对象也统一转化为字符串)4.github地址https://github.com/wangyebin上代码#import"NSObject+WYBExtension.h"@implementationNSObject(WYBExtension
- NSValue
至于么_ni
#importtypedefstruct{intx;inty;}TRPoint;typedefstruct{charch;doubled;}TRMyData;intmain(intargc,constchar*argv[]){@autoreleasepool{TRPointp;p.x=10;p.y=15;NSLog(@"%d%d",p.x,p.y);//1015NSValue*value=[NSV
- iOS 开发正则匹配字符串中固定字符 如搜索高亮显示 返回所有range
雷海洋
常规方法://获取一个字符在字符串中出现的所有位置返回一个被NSValue包装的NSRange数组-(NSArray*)rangeOfSubString:(NSString*)subStrinString:(NSString*)wholeString{if(subStr==nil&&[subStrisEqualToString:@""]){returnnil;}NSMutableArray*aRa
- 将所有坐标存到数组集合中
Qy_iOS
//将所有圆点的坐标存到数组中NSValue*nsValue=[NSValuevalueWithCGPoint:point];[_btnPointArraddObject:nsValue];//将NSValue转换成CGRect原来类型的数值CGRectrect=[[arrayobjectAtIndex:0]CGRectValue];UILabel*lableTest=[[UILabelalloc
- iOS开发中的集合类型NSSet, NSArray, NS,OrderedSet, NSDictionary, NSPointerArray, NSMapTable, NSHashTable
MiniCoder
iOS中有很多种集合类型,最为常见的可能就NSArray、NSDictionary、NSSet,但其实还有NSPointerArray、NSMapTable、NSHashTable等类型,虽然后面三个类型不常见,但是它们能在关键时刻,「救你一命」先来看看传统的集合类型都有哪些短板:放到集合中的对象,只能强引用如果想要弱引用,要先用NSValue打包不能放入nil而对于NSPointerArray、
- NSMapTable、NSHashTable和NSPointerArray
xiao_k龙
在iOS使用集合主要是NSArray、NSDictionary和NSSet,这三个集合的特点有这几个:可是这些都是对元素做强引用的,引用计数器+1。不可以使用弱引用,如果要使用弱引用,就要用NSValue包装不可以放入nil可是有时候需要集合的引用为弱引用,上面的这些集合就用不了了。而接下来介绍的集合就是解决这个问题的。NSPointerArray先来看看NSPointerArray的特点有哪些和
- iOS 集合如何弱引用对象
Caolongs
一.使用NSValueNSValue可以弱引用保存一个对象,我们可以使用这种方法间接的引用。NSMutableArray*array=@[].mutableCopy;//添加NSObject*obj=[NSObjectnew];[arrayaddObject:[NSValuevalueWithNonretainedObject:obj]];//读取NSValue*value=array[0];NS
- IOS动画简单知识
lg大大
1.layer的CATransform3D属性.//旋转CATransform3DMakeRotation(M_PI,1,1,0);//平移CATransform3DMakeTranslation(x,y,z)//缩放CATransform3DMakeScale(x,y,z);//kvc设置属性NSValue*value=[NSValuevalueWithCATransform3D:CATrans
- 结构体转成对象
HCL黄
比如要将CATransform3DMakeRotation(M_PI,1,1,0)这个结构体转为对象,这个时候就要用到NSValue对象了NSValue*value=[NSValuevalueWithCATransform3D:CATransform3DMakeRotation(M_PI,1,1,0)];[self.view.layersetValue:valueforKeyPath:@"tran
- iOS中的NSNumber与NSValue
皆为序幕_so
NSNumber(只能包装数字类型)NSNumber*num1=[NSNumbernumberWithInt:10];NSNumber*num2=[NSNumbernumberWithFloat:10.1];NSNumber*num3=[NSNumbernumberWithBool:YES];NSNumber*num4=@10;NSValue(可以包装结构体)+(NSValue*)valueWit
- iOS OC基本数据类型~封装和拆包
石虎132
//联系人:石虎QQ:1224614774昵称:嗡嘛呢叭咪哄一、封装和拆包的概念我们将C和OC中的基本数据类型(值类型)转换成对象(引用类型)的过程,叫做封装。相对应的也有一个将对象转变成基本数据类型,此过程叫做拆包。功能:将OC和C当中的基本数据类型转换成实例对象,即将'值类型'转换成'引用类型'二、NSValue类型封装、拆包1.NSRange包含了两个成员,location以及length。
- NSNumber与NSInteger
IOS_Wek
NSInteger、CGFloat是基本数据类型,而NSValue、NSNumber是包装类,NSValue是NSNumber的父类。NSNumber是个对象,不能直接通过(int)来转换,而只能通过[NumberintegerValue]方法来获取值。
- GeekBand Objective-C 集合类型
东忙忙西茫茫
1.数组数组是一个有序的元素序列,其内部只能存放对象类型,对于基本数据类型需要用NSNumber包装成对象后存放,对于C语言的Struct类型,需要用NSValue包装对象后存放。它的索引是从0开始,其索引大小大于数组长度时,会抛出索引越界运行时异常。1.1NSArray(固定数组)NSArray具有常量性,其长度和元素均不能被更改。但元素对象指针指向的内容可以修改。遍历方式://forin方式,
- 数组笔记(极客班)
SkyFang2016
NSArray有三种方法初始化:1,工厂方法:arrayWithObjects,加nil结束;2,初始化器方式:initWithObjects,加nil结束;3,@[]直接在里面加元素,不用加nil结束;NSArray里面的元素必须是NSObject子类;结构体组成对象方法:NSValue*temp=[NSValuevalue:&pointwithObjCType:@encode(Point)];
- (四) IOS学习之--NSNumber & NSValue
CodingEleven
-NSNumber现在有一个问题,如果想把基本数据(比如NSInteger,float,char,bool...)放进NSArray\NSDictionary中,但是NSArray\NSDictionary只能存放OC对象,不能存放基本数据,因此需要把数据转成OC对象,NSNumber正好承担了这一封装任务.NSIntegernum=100;CGFloatf=9.01;BOOLflag=YES;1
- NSNumber与NSValue
struggle3g
NSNumber与NSValue的作用由于在OC的结合当中NSdictionary,NSSet集合中只能添加一些对象而不能存储一些基础数据NSNumber只能包装基础类型数据,比如char,int,float,double,BOOL等。NSValue可以包含任何一个对象,并可以包含系统自定义的一些结构体,数据结构等,
- iOS NSValue&NSNumber&NSDecimal
青椒辣不辣
NSValue存储结构体typedefstructParameterStruct{inta;intb;}MyStruct;//存储MyStructmystruct={10,20};NSValue*value=[NSValuevalueWithBytes:&mystructobjCType:@encode(MyStruct)];//获取MyStructstruceBack;[valuegetValu
- iOS 7.0.4 和 7.1 上计算文字高度有误差的解决方法
栋飞同学
iOS
最近写项目计算文字高度那里在7.0.4和7.1上遇见文字高度有误差的问题,一般写我就直接用系统提供的方法,计算高度,如下://得到文字的高度+(NSValue*)getStringWithRect:(NSString*)aStringviewWidth:(NSInteger)widthfont:(float)font{CGSizesize;if(ISIOS7){NSDictionary*attri
- 第五章:面向对象(下)
xiaoxiaobukuang
疯狂iOS(上)
一、Objective-C的包装类c语言中包括的基本数据类型(int,short,long,float,double等)都不是对象,OC提供了NSValue,NSNumber来封装C语言的基本类型。1、他们不是包装类(1)、NSInteger:大致等于long型整数;(2)、NSUInteger:大致等于unsignedlong型整型;(3)、CGFloat:在64为平台上大致相当于double;
- iOS 中集合如何弱引用对象
weixin_33921089
1.使用NSValueNSValue可以弱引用保存一个对象,我们可以使用这种方法间接的引用。NSValue*value=[NSValuevalueWithNonretainedObject:@selector(class)];[arrayaddObject:value];2.使用NSPointerArray,NSMapTable,NSHashTable以上三个类型的用法分别对应NSMutableA
- iOS如何在容器类(如NSMutableSet)中使用弱引用(weak reference)
jeffasd
iOS_OC
http://blog.sina.com.cn/s/blog_48d4cf2d0102v1jh.html在项目中有某个功能需要用到多个delegate对象,这就需要把delegate放到容器中,但又不想保存强引用导致delegate对象不能被释放。所以希望能在容器中只保存delegate对象的弱引用。搜索发现大家常用的方法应该是采用NSValue的valueWithNonretainedObjec
- iOS 中集合如何弱引用对象
D_SJ
1.使用NSValueNSValue可以弱引用保存一个对象,我们可以使用这种方法间接的引用。NSValue*value=[NSValuevalueWithNonretainedObject:@selector(class)];[arrayaddObject:value];复制代码2.使用NSPointerArray,NSMapTable,NSHashTable以上三个类型的用法分别对应NSMuta
- JVM StackMapTable 属性的作用及理解
lijingyao8206
jvm字节码Class文件StackMapTable
在Java 6版本之后JVM引入了栈图(Stack Map Table)概念。为了提高验证过程的效率,在字节码规范中添加了Stack Map Table属性,以下简称栈图,其方法的code属性中存储了局部变量和操作数的类型验证以及字节码的偏移量。也就是一个method需要且仅对应一个Stack Map Table。在Java 7版
- 回调函数调用方法
百合不是茶
java
最近在看大神写的代码时,.发现其中使用了很多的回调 ,以前只是在学习的时候经常用到 ,现在写个笔记 记录一下
代码很简单:
MainDemo :调用方法 得到方法的返回结果
- [时间机器]制造时间机器需要一些材料
comsci
制造
根据我的计算和推测,要完全实现制造一台时间机器,需要某些我们这个世界不存在的物质
和材料...
甚至可以这样说,这种材料和物质,我们在反应堆中也无法获得......
 
- 开口埋怨不如闭口做事
邓集海
邓集海 做人 做事 工作
“开口埋怨,不如闭口做事。”不是名人名言,而是一个普通父亲对儿子的训导。但是,因为这句训导,这位普通父亲却造就了一个名人儿子。这位普通父亲造就的名人儿子,叫张明正。 张明正出身贫寒,读书时成绩差,常挨老师批评。高中毕业,张明正连普通大学的分数线都没上。高考成绩出来后,平时开口怨这怨那的张明正,不从自身找原因,而是不停地埋怨自己家庭条件不好、埋怨父母没有给他创造良好的学习环境。
- jQuery插件开发全解析,类级别与对象级别开发
IT独行者
jquery开发插件 函数
jQuery插件的开发包括两种: 一种是类级别的插件开发,即给
jQuery添加新的全局函数,相当于给
jQuery类本身添加方法。
jQuery的全局函数就是属于
jQuery命名空间的函数,另一种是对象级别的插件开发,即给
jQuery对象添加方法。下面就两种函数的开发做详细的说明。
1
、类级别的插件开发 类级别的插件开发最直接的理解就是给jQuer
- Rome解析Rss
413277409
Rome解析Rss
import java.net.URL;
import java.util.List;
import org.junit.Test;
import com.sun.syndication.feed.synd.SyndCategory;
import com.sun.syndication.feed.synd.S
- RSA加密解密
无量
加密解密rsa
RSA加密解密代码
代码有待整理
package com.tongbanjie.commons.util;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerat
- linux 软件安装遇到的问题
aichenglong
linux遇到的问题ftp
1 ftp配置中遇到的问题
500 OOPS: cannot change directory
出现该问题的原因:是SELinux安装机制的问题.只要disable SELinux就可以了
修改方法:1 修改/etc/selinux/config 中SELINUX=disabled
2 source /etc
- 面试心得
alafqq
面试
最近面试了好几家公司。记录下;
支付宝,面试我的人胖胖的,看着人挺好的;博彦外包的职位,面试失败;
阿里金融,面试官人也挺和善,只不过我让他吐血了。。。
由于印象比较深,记录下;
1,自我介绍
2,说下八种基本类型;(算上string。楼主才答了3种,哈哈,string其实不是基本类型,是引用类型)
3,什么是包装类,包装类的优点;
4,平时看过什么书?NND,什么书都没看过。。照样
- java的多态性探讨
百合不是茶
java
java的多态性是指main方法在调用属性的时候类可以对这一属性做出反应的情况
//package 1;
class A{
public void test(){
System.out.println("A");
}
}
class D extends A{
public void test(){
S
- 网络编程基础篇之JavaScript-学习笔记
bijian1013
JavaScript
1.documentWrite
<html>
<head>
<script language="JavaScript">
document.write("这是电脑网络学校");
document.close();
</script>
</h
- 探索JUnit4扩展:深入Rule
bijian1013
JUnitRule单元测试
本文将进一步探究Rule的应用,展示如何使用Rule来替代@BeforeClass,@AfterClass,@Before和@After的功能。
在上一篇中提到,可以使用Rule替代现有的大部分Runner扩展,而且也不提倡对Runner中的withBefores(),withAfte
- [CSS]CSS浮动十五条规则
bit1129
css
这些浮动规则,主要是参考CSS权威指南关于浮动规则的总结,然后添加一些简单的例子以验证和理解这些规则。
1. 所有的页面元素都可以浮动 2. 一个元素浮动后,会成为块级元素,比如<span>,a, strong等都会变成块级元素 3.一个元素左浮动,会向最近的块级父元素的左上角移动,直到浮动元素的左外边界碰到块级父元素的左内边界;如果这个块级父元素已经有浮动元素停靠了
- 【Kafka六】Kafka Producer和Consumer多Broker、多Partition场景
bit1129
partition
0.Kafka服务器配置
3个broker
1个topic,6个partition,副本因子是2
2个consumer,每个consumer三个线程并发读取
1. Producer
package kafka.examples.multibrokers.producers;
import java.util.Properties;
import java.util.
- zabbix_agentd.conf配置文件详解
ronin47
zabbix 配置文件
Aliaskey的别名,例如 Alias=ttlsa.userid:vfs.file.regexp[/etc/passwd,^ttlsa:.:([0-9]+),,,,\1], 或者ttlsa的用户ID。你可以使用key:vfs.file.regexp[/etc/passwd,^ttlsa:.: ([0-9]+),,,,\1],也可以使用ttlsa.userid。备注: 别名不能重复,但是可以有多个
- java--19.用矩阵求Fibonacci数列的第N项
bylijinnan
fibonacci
参考了网上的思路,写了个Java版的:
public class Fibonacci {
final static int[] A={1,1,1,0};
public static void main(String[] args) {
int n=7;
for(int i=0;i<=n;i++){
int f=fibonac
- Netty源码学习-LengthFieldBasedFrameDecoder
bylijinnan
javanetty
先看看LengthFieldBasedFrameDecoder的官方API
http://docs.jboss.org/netty/3.1/api/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.html
API举例说明了LengthFieldBasedFrameDecoder的解析机制,如下:
实
- AES加密解密
chicony
加密解密
AES加解密算法,使用Base64做转码以及辅助加密:
package com.wintv.common;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import sun.misc.BASE64Decod
- 文件编码格式转换
ctrain
编码格式
package com.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
- mysql 在linux客户端插入数据中文乱码
daizj
mysql中文乱码
1、查看系统客户端,数据库,连接层的编码
查看方法: http://daizj.iteye.com/blog/2174993
进入mysql,通过如下命令查看数据库编码方式: mysql> show variables like 'character_set_%'; +--------------------------+------
- 好代码是廉价的代码
dcj3sjt126com
程序员读书
长久以来我一直主张:好代码是廉价的代码。
当我跟做开发的同事说出这话时,他们的第一反应是一种惊愕,然后是将近一个星期的嘲笑,把它当作一个笑话来讲。 当他们走近看我的表情、知道我是认真的时,才收敛一点。
当最初的惊愕消退后,他们会用一些这样的话来反驳: “好代码不廉价,好代码是采用经过数十年计算机科学研究和积累得出的最佳实践设计模式和方法论建立起来的精心制作的程序代码。”
我只
- Android网络请求库——android-async-http
dcj3sjt126com
android
在iOS开发中有大名鼎鼎的ASIHttpRequest库,用来处理网络请求操作,今天要介绍的是一个在Android上同样强大的网络请求库android-async-http,目前非常火的应用Instagram和Pinterest的Android版就是用的这个网络请求库。这个网络请求库是基于Apache HttpClient库之上的一个异步网络请求处理库,网络处理均基于Android的非UI线程,通
- ORACLE 复习笔记之SQL语句的优化
eksliang
SQL优化Oracle sql语句优化SQL语句的优化
转载请出自出处:http://eksliang.iteye.com/blog/2097999
SQL语句的优化总结如下
sql语句的优化可以按照如下六个步骤进行:
合理使用索引
避免或者简化排序
消除对大表的扫描
避免复杂的通配符匹配
调整子查询的性能
EXISTS和IN运算符
下面我就按照上面这六个步骤分别进行总结:
- 浅析:Android 嵌套滑动机制(NestedScrolling)
gg163
android移动开发滑动机制嵌套
谷歌在发布安卓 Lollipop版本之后,为了更好的用户体验,Google为Android的滑动机制提供了NestedScrolling特性
NestedScrolling的特性可以体现在哪里呢?<!--[if !supportLineBreakNewLine]--><!--[endif]-->
比如你使用了Toolbar,下面一个ScrollView,向上滚
- 使用hovertree菜单作为后台导航
hvt
JavaScriptjquery.nethovertreeasp.net
hovertree是一个jquery菜单插件,官方网址:http://keleyi.com/jq/hovertree/ ,可以登录该网址体验效果。
0.1.3版本:http://keleyi.com/jq/hovertree/demo/demo.0.1.3.htm
hovertree插件包含文件:
http://keleyi.com/jq/hovertree/css
- SVG 教程 (二)矩形
天梯梦
svg
SVG <rect> SVG Shapes
SVG有一些预定义的形状元素,可被开发者使用和操作:
矩形 <rect>
圆形 <circle>
椭圆 <ellipse>
线 <line>
折线 <polyline>
多边形 <polygon>
路径 <path>
- 一个简单的队列
luyulong
java数据结构队列
public class MyQueue {
private long[] arr;
private int front;
private int end;
// 有效数据的大小
private int elements;
public MyQueue() {
arr = new long[10];
elements = 0;
front
- 基础数据结构和算法九:Binary Search Tree
sunwinner
Algorithm
A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all
- 项目出现的一些问题和体会
Steven-Walker
DAOWebservlet
第一篇博客不知道要写点什么,就先来点近阶段的感悟吧。
这几天学了servlet和数据库等知识,就参照老方的视频写了一个简单的增删改查的,完成了最简单的一些功能,使用了三层架构。
dao层完成的是对数据库具体的功能实现,service层调用了dao层的实现方法,具体对servlet提供支持。
&
- 高手问答:Java老A带你全面提升Java单兵作战能力!
ITeye管理员
java
本期特邀《Java特种兵》作者:谢宇,CSDN论坛ID: xieyuooo 针对JAVA问题给予大家解答,欢迎网友积极提问,与专家一起讨论!
作者简介:
淘宝网资深Java工程师,CSDN超人气博主,人称“胖哥”。
CSDN博客地址:
http://blog.csdn.net/xieyuooo
作者在进入大学前是一个不折不扣的计算机白痴,曾经被人笑话过不懂鼠标是什么,