模板方法模式: 模板方法模式,就是定义一个操作中的算法框架,而将一些步骤延迟到子类中,使得子类可以不改变一个算法的结构可重新定义该算法的某些特定步骤。简而言之,就是定义一个抽象类,在该抽象类中,有一些需要子类特定实现的方法,和一个基本已经实现不改变的方法,而在这个固定的方法中调用那些需要子类实现的....
分类:
其他好文 时间:
2014-12-03 22:46:23
阅读次数:
161
1.1 定义 为其他对象提供一种代理,以控制这个对象的访问。 其实就是两个类实现一个接口或抽象类,在A类中实例化B类的对象,那么A类的就能代理B类实现接口的方法。1.2 类图 Porxy代理类中声明了RealSubject类的实例,在需要调用他们都实现的方法时,调用RealSubject实例...
分类:
其他好文 时间:
2014-12-03 22:46:55
阅读次数:
143
1 #include2 using namespace std; 3 AllocConsole();4 freopen("CONIN$", "r+t", stdin); // 重定向 STDIN5 freopen("CONOUT$", "w+t", stdout); // 重定向STDOUT 在最开...
分类:
其他好文 时间:
2014-12-03 22:45:29
阅读次数:
154
云平台中镜像还是很重要的,提供各种定制化的镜像使得用户体验更好。最开始玩OpenStack的时候用的是安装文档中提到的cirros,其密码cubswin:) 刚开始感觉很怪,现在已经可以随手打出。ps:打的还很熟练:-)然后慢慢开始想尝试各种镜像,于是乎在网上搜了很多。如下:官方文档 http://...
分类:
其他好文 时间:
2014-12-03 22:46:57
阅读次数:
247
Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order....
分类:
其他好文 时间:
2014-12-03 22:47:54
阅读次数:
153
现在使用的是Git + Gerrit的代码管理工具。新的项目组里面,代码都是open。一有时间,只要你想,可以查看组内人员提交的代码。新的老大对代码的审查很是到位,对于类之间是提炼方法还是继承。完全是扣得很紧。从中可以学到很多。不过对于底层的代码研读上来说,刚毕业的人读起来确实基本上只能增加挫...
分类:
其他好文 时间:
2014-12-03 22:44:58
阅读次数:
132
#include#define SWAP(VALUE1,VALUE2) \do{\ VALUE1 += VALUE2;\ VALUE2 = VALUE1 - VALUE2;\ VALUE1 = VALUE1 - VALUE2;\}while(0)int main(){ dou...
分类:
其他好文 时间:
2014-12-03 22:47:16
阅读次数:
144
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:
其他好文 时间:
2014-12-03 22:46:11
阅读次数:
192
/* Navicat MySQL Data Transfer Source Server : lj Source Server Version : 50129 Source Host : 404 Source Database : cypheta Target Server Type : MYSQL...
分类:
其他好文 时间:
2014-12-03 22:44:19
阅读次数:
6912
前面《[ruby on rails] 跟我学之Hello World》提到,路由对应的文件是 config/routes.rb实际上我们只是添加了一句代码: resources :posts但是这个代码默认的路由却有多个,可以通过 rake routes进行查看,如下:root@tommy:/ho....
分类:
其他好文 时间:
2014-12-03 22:44:29
阅读次数:
101
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.public class Solution { public...
分类:
其他好文 时间:
2014-12-03 22:43:28
阅读次数:
191
Git初学者的个人经验记录,仅供参考1. Pull is not possible because you have unmerged files.症状:pull的时候$ git pullPull is not possible because you have unmerged files.Ple...
分类:
其他好文 时间:
2014-12-03 22:45:29
阅读次数:
112
/******************************************************************** 文件名: $FILE_BASE$.$FILE_EXT$** 版 权: (C) hanframe@163.com sz** 创建人: FlameHong** .....
分类:
其他好文 时间:
2014-12-03 22:45:19
阅读次数:
152
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi...
分类:
其他好文 时间:
2014-12-03 22:43:18
阅读次数:
153
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2014-12-03 22:44:08
阅读次数:
134
有时候我们重写父类的init方法时不注意将init后面的第一个字母写成了小写,在这个方法里面又调用父类的初始化方法(self = [super init];)时会报错,错误信息如下:error:Cannot assign to 'self' outside of a method in the...
分类:
其他好文 时间:
2014-12-03 22:45:04
阅读次数:
109
原文链接:http://www.vaikan.com/how-to-maintain-programmers-health/相信大家已经注意到了,程序员的大部分时间都花在电脑桌前编程,这会损害程序员的健康。其实不需要多么复杂的养生,你只需每天做一些小小的改变,就可以摆脱病痛、保持健康。变换姿势虽然站...
分类:
其他好文 时间:
2014-12-03 22:44:15
阅读次数:
169