博客园  :: 首页  :: 新随笔  :: 订阅 订阅  :: 管理
上一页 1 2 3 4 5 6 ··· 14 下一页

2013年3月10日

摘要: 引用自:Tutorial: Detecting When A User Blows Into The MicIf, a couple of years back, you’d told me that people would expect to be able to shake their phone or blow into the mic to make something happen I would have laughed. And here we are.Detecting a shake gesture is straightforward, all the more so i 阅读全文

posted @ 2013-03-10 21:01 扬名 阅读(2896) 评论(0) 推荐(0) 编辑

2013年2月23日

摘要: 对于线程任务比较轻量,线程请求又比较多的情况,频繁的创建和销毁线程是非常消耗资源且低效的。这时候,就轮到线程池技术大显身手了。线程池技术可以提高资源的利用率,即使面对突发性的大量请求,也不会产生大量线程,造成服务器崩溃。一般一个简单线程池至少包含下列组成部分:线程池管理器(ThreadPoolManager):用于创建并管理线程池。工作线程(WorkThread): 线程池中线程。任务接口(Task):每个任务必须实现的接口,以供工作线程调度任务的执行。任务队列:用于存放没有处理的任务。提供一种缓冲机制。线程相关接口:下面是一个线程池的示例,来自http://hi.baidu.com/boah 阅读全文

posted @ 2013-02-23 21:54 扬名 阅读(419) 评论(0) 推荐(0) 编辑

2013年2月18日

摘要: 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 int main() { 6 string strA = "Copy on write"; 7 string strB = strA; 8 string strC = strA; 9 printf("strA: %p\r\n", strA.c_str());10 printf("strB: %p\r\n", strB.c_str());11 printf("strC 阅读全文

posted @ 2013-02-18 22:17 扬名 阅读(915) 评论(0) 推荐(1) 编辑

摘要: 当程序崩溃的时候怎么办 PART-1当程序崩溃的时候怎么办 PART-2 阅读全文

posted @ 2013-02-18 21:07 扬名 阅读(286) 评论(0) 推荐(0) 编辑

摘要: #define foreach(container,it) for(typeof((container).begin()) it = (container).begin();it!=(container).end();++it)demo:#include <iostream>#include <vector>#include <set>#include <map>#include <string>using namespace std; #define foreach(container,it) for(typeof((contain 阅读全文

posted @ 2013-02-18 20:53 扬名 阅读(1299) 评论(0) 推荐(0) 编辑

摘要: In software, astack overflowoccurs when too muchmemoryis used on thecall stack. The call stack contains a limited amount of memory, often determined at the start of the program. The size of the call stack depends on many factors, including the programming language, machine architecture, multi-thread 阅读全文

posted @ 2013-02-18 20:11 扬名 阅读(606) 评论(0) 推荐(0) 编辑

2013年2月17日

摘要: // malloc 的写法char* buffer = (char*)malloc(1024);if(buffer) { printf("malloc success!\r\n"); }free(buffer);// new的写法try { char* buffer = new char[1024];}catch(...) { printf("operator new error!\r\n");}delete []buffer;对于malloc方式申请的内存,通过是否是零指针区别;对于new方式申请的内存,通过C++异常机制处理。小细节,大问题。 阅读全文

posted @ 2013-02-17 22:11 扬名 阅读(1655) 评论(0) 推荐(1) 编辑

2013年2月13日

摘要: 如今大部分编译器的随机数算法还是线性同余算法,简称LCG。线性同余算法(LCG):http://en.wikipedia.org/wiki/Linear_congruential_generatorALinear Congruential Generator(LCG) represents one of the oldest and best-knownpseudorandomnumbergeneratoralgorithms.The generator is defined by therecurrencerelation:whereis thesequenceof pseudorandom 阅读全文

posted @ 2013-02-13 22:18 扬名 阅读(3684) 评论(0) 推荐(0) 编辑

2012年12月10日

摘要: /* NSNotification.h Copyright (c) 1994-2012, Apple Inc. All rights reserved.*/#import <Foundation/NSObject.h>@class NSString, NSDictionary, NSOperationQueue;/**************** Notifications ****************/@interface NSNotification : NSObject <NSCopying, NSCoding>- (NSString *)name;- (id 阅读全文

posted @ 2012-12-10 20:40 扬名 阅读(3928) 评论(0) 推荐(1) 编辑

2012年11月24日

摘要: XXTEA算法的结构非常简单,只需要执行加法、异或和寄存的硬件即可,且软件实现的代码非常短小,具有可移植性。维基百科地址:http://en.wikipedia.org/wiki/XXTEAXXTEA可对连续内存数据进行方便快速的加密解密,且比较安全,但其使用不是很方便,因此有了此次封装。封装好的接口如下://// XXTEA.h//// Created by Yuming on 12-7-24.// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.///* * 此类是对XXTEA官方算法进行的封装,XXTEA信息详见... 阅读全文

posted @ 2012-11-24 23:49 扬名 阅读(12108) 评论(1) 推荐(3) 编辑

上一页 1 2 3 4 5 6 ··· 14 下一页