04 2015 档案

摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对访问者模式是这样说的:表示一个作用于某对象结构中的各元素的操作。它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作。访问者模式把数据结构和作用于结构上的操作之间的耦合解脱开,使得操作集合可以相对自由地演化。该模式的目的是要把处理从数... 阅读全文
posted @ 2015-04-24 16:20 穆穆兔兔 阅读(444) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对状态模式是这样说的:允许一个对象在其内部状态改变时改变它的行为。对象看起来似乎修改了它的类。状态模式的重点在于状态转换,很多时候,对于一个对象的状态,我们都是让这个对象包含一个状态的属性,这个状态属性记录着对象的具体状态,根据状态的不同使用分支... 阅读全文
posted @ 2015-04-24 15:30 穆穆兔兔 阅读(279) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对观察者模式是这样说的:定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新。当一个对象发生了变化,关注它的对象就会得到通知;这种交互也称为发布-订阅(publish-subscribe)。目标是... 阅读全文
posted @ 2015-04-24 15:07 穆穆兔兔 阅读(421) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对备忘录模式是这样说的:在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样以后就可将该对象恢复到原先保存的状态。类图和实例:简单的模式实例:#include #include using namespace std;... 阅读全文
posted @ 2015-04-24 11:37 穆穆兔兔 阅读(315) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对中介者模式是这样说的:用一个中介对象来封装一系列的对象交互。中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。我们都知道,面向对象设计鼓励将行为分布到各个对象中。但是,这种分布可能会导致对象间有许多连接。在... 阅读全文
posted @ 2015-04-24 11:28 穆穆兔兔 阅读(267) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对迭代器模式是这样说的:提供一种方法顺序访问一个聚合对象中各个元素,而又不需要暴露该对象的内部表示。类图和实例:迭代器模式由以下角色组成:1.迭代器角色(Iterator):迭代器角色负责定义访问和遍历元素的接口。2.具体迭代器角色(Concre... 阅读全文
posted @ 2015-04-24 11:14 穆穆兔兔 阅读(285) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对解释器模式是这样说的:给定一个语言,定义它的文法的一种表示,并定义一个解释器,这个解释器使用该表示来解释语言中的句子。如果一种特定类型的问题发生的频率足够高,那么可能就值得将该问题的各个实例表述为一个简单语言中的句子。这样就可以构建一个解释器,... 阅读全文
posted @ 2015-04-24 10:55 穆穆兔兔 阅读(251) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对策略模式是这样说的:定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。该模式使得算法可独立于使用它的客户而变化。策略模式为了适应不同的需求,只把变化点封装了,这个变化点就是实现不同需求的算法,但是,用户需要知道各种算法的具体情况。就... 阅读全文
posted @ 2015-04-23 18:12 穆穆兔兔 阅读(230) 评论(0) 推荐(0) 编辑
摘要:Command 模式通过将请求封装到一个对象(Command)中,并将请求的接受者存放到具体的 ConcreteCommand 类中(Receiver)中,从而实现调用操作的对象和操作的具体实现者之间的解耦。 在GOF的《设计模式:可复用面向对象软件的基础》一书中对命令模式是这样说的:将一个请求封... 阅读全文
posted @ 2015-04-23 18:01 穆穆兔兔 阅读(207) 评论(0) 推荐(0) 编辑
摘要:转 http://blog.csdn.net/wuzhekai1985 http://www.jellythink.com/archives/878向项目经理提交了休假申请,我的项目经理向项目主管提交了我的休假申请,项目主管向部门经理提交了我的休假申请;最后,部门经理同意了我的休假申请。是的,一个简... 阅读全文
posted @ 2015-04-23 17:27 穆穆兔兔 阅读(243) 评论(0) 推荐(0) 编辑
摘要:转http://www.jellythink.com/archives/407在GOF的《设计模式:可复用面向对象软件的基础》一书中对模板方法模式是这样说的:定义一个操作中的算法骨架,而将一些步骤延迟到子类中。TemplateMethod使得子类可以不改变一个算法的接口即可重定义改算法的某些特定步骤... 阅读全文
posted @ 2015-04-23 17:05 穆穆兔兔 阅读(202) 评论(0) 推荐(0) 编辑
摘要:在GOF的《设计模式:可复用面向对象软件的基础》一书中对代理模式是这样说的:为其他对象提供一种代理以控制对这个对象的访问。结合上面的游戏代理的例子和下面的图,我们来进行分析一下。以前你是这样玩游戏:现在有了游戏代理,你是这样玩游戏:代理服务器干了什么?它代替你去和游戏服务器进行交互。它访问游戏服务器... 阅读全文
posted @ 2015-04-23 16:55 穆穆兔兔 阅读(344) 评论(0) 推荐(0) 编辑
摘要:关键字explicit可以禁止“单参数构造函数”被用于自动类型转换class Stack{explicit Stack(int size);};没有explicit的话Stack s = 40;能编译通过而有explicit则不能,必需Stack s(40); 阅读全文
posted @ 2015-04-23 16:49 穆穆兔兔 阅读(176) 评论(0) 推荐(0) 编辑
摘要:外观模式应该是用的很多的一种模式,特别是当一个系统很复杂时,系统提供给客户的是一个简单的对外接口,而把里面复杂的结构都封装了起来。客户只需使用这些简单接口就能使用这个系统,而不需要关注内部复杂的结构。DP一书的定义:为子系统中的一组接口提供一个一致的界面, 外观模式定义了一个高层接口,这个接口使得这... 阅读全文
posted @ 2015-04-23 16:30 穆穆兔兔 阅读(203) 评论(0) 推荐(0) 编辑
摘要:转http://blog.csdn.net/wuzhekai1985/article/details/6670298问题 在面向对象系统的设计何实现中,创建对象是最为常见的操作。这里面就有一个问题:如果一个应用程序使用了太多的对象,就会造成很大的存储开销。特别是对于大量轻量级(细粒度)的对象,比... 阅读全文
posted @ 2015-04-23 16:16 穆穆兔兔 阅读(180) 评论(0) 推荐(0) 编辑
摘要:转:http://www.jellythink.com/archives/171#prettyPhoto什么是装饰模式?在GOF的《设计模式:可复用面向对象软件的基础》一书中对装饰模式是这样说的:动态地给一个对象添加一些额外的职责。就增加功能来说,Decorator模式相比生成子类更为灵活。装饰模式... 阅读全文
posted @ 2015-04-22 17:18 穆穆兔兔 阅读(304) 评论(1) 推荐(0) 编辑
摘要:DP书上给出的定义:将对象组合成树形结构以表示“部分-整体”的层次结构。组合使得用户对单个对象和组合对象的使用具有一致性。注意两个字“树形”。这种树形结构在现实生活中随处可见,比如一个集团公司,它有一个母公司,下设很多家子公司。不管是母公司还是子公司,都有各自直属的财务部、人力资源部、销售部等。对于... 阅读全文
posted @ 2015-04-22 17:00 穆穆兔兔 阅读(207) 评论(0) 推荐(0) 编辑
摘要:flaot转int时,会直接舍弃小数为,但是当把f所在的地址的数据当成int解析时,就是另外的情况了。#includeusing namespace std;int main(){ float f= 5.2; int *p = (int*)&f; cout << (int)... 阅读全文
posted @ 2015-04-17 23:55 穆穆兔兔 阅读(489) 评论(0) 推荐(0) 编辑
摘要:在 Adapter 模式的结构图中可以看到,类模式的 Adapter 采用继承的方式复用 Adaptee的接口,而在对象模式的 Adapter 中我们则采用组合的方式实现 Adaptee 的复用类模式的adapter#includeusing namespace std;class Target ... 阅读全文
posted @ 2015-04-17 13:58 穆穆兔兔 阅读(237) 评论(0) 推荐(0) 编辑
摘要:#includeusing namespace std;class AbstractionImp{ public: virtual ~AbstractionImp(); virtual void Operation() = 0; protected: ... 阅读全文
posted @ 2015-04-17 13:39 穆穆兔兔 阅读(212) 评论(0) 推荐(0) 编辑
摘要:C++类里面,我们经常可以看到析构函数是虚函数,这个虚函数有什么作用吗?我们可以通过一个很简单的例子来看看虚析构函数的作用。#includeusing namespace std;class CBase{ public: /*virtual*/ ~CBase() {... 阅读全文
posted @ 2015-04-17 13:01 穆穆兔兔 阅读(333) 评论(0) 推荐(0) 编辑
摘要:设计模式:可复用面向对象软件的基础》(DP)本文介绍原型模式和模板方法模式的实现。首先介绍原型模式,然后引出模板方法模式。 DP书上的定义为:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。其中有一个词很重要,那就是拷贝。可以说,拷贝是原型模式的精髓所在。举个现实中的例子来介绍原... 阅读全文
posted @ 2015-04-17 11:19 穆穆兔兔 阅读(313) 评论(0) 推荐(0) 编辑
摘要:转载http://blog.csdn.net/wuzhekai1985/article/details/6667467 建造者模式的定义将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示(DP)。《大话设计模式》举了一个很好的例子——建造小人,一共需建造6个部分,头部、身体、左... 阅读全文
posted @ 2015-04-17 11:02 穆穆兔兔 阅读(360) 评论(0) 推荐(0) 编辑
摘要:转 http://www.cnblogs.com/rainman/archive/2013/05/01/3053703.html#m51、概述2、原始表3、简单Group By4、Group By 和 Order By5、Group By中Select指定的字段限制6、Group By All7、G... 阅读全文
posted @ 2015-04-16 16:35 穆穆兔兔 阅读(195) 评论(0) 推荐(0) 编辑
摘要:转处 http://blog.csdn.net/wuzhekai1985软件领域中的设计模式为开发人员提供了一种使用专家设计经验的有效途径。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态,真正领悟设计模式的精髓是可能一个漫长的过程,需要大量实践经验的积累。最近看设计模式的书,对于每个模... 阅读全文
posted @ 2015-04-16 15:47 穆穆兔兔 阅读(317) 评论(0) 推荐(0) 编辑
摘要:转载http://blog.csdn.net/wuzhekai1985 软件领域中的设计模式为开发人员提供了一种使用专家设计经验的有效途径。设计模式中运用了面向对象编程语言的重要特性:封装、继承、多态,真正领悟设计模式的精髓是可能一个漫长的过程,需要大量实践经验的积累。最近看设计模式的书,对于每个模... 阅读全文
posted @ 2015-04-16 14:53 穆穆兔兔 阅读(378) 评论(0) 推荐(0) 编辑
摘要:从网络上搜集了一些设计模式 C++的资料:我基本上是copy或是修改他们的博客,这里感谢作者们!http://design-patterns.readthedocs.org/zh_CN/latest/index.html 图说设计模式http://blog.csdn.net/wuzhekai1985... 阅读全文
posted @ 2015-04-16 11:37 穆穆兔兔 阅读(300) 评论(0) 推荐(0) 编辑
摘要:http://bbs.byr.cn/#!article/CPP/86336?p=1下列代码给出输出结果:#include"stdafx.h"#include #include "stdlib.h" using namespace std;int main(void){ const int a ... 阅读全文
posted @ 2015-04-15 13:27 穆穆兔兔 阅读(484) 评论(0) 推荐(0) 编辑
摘要:在UML类图中,常见的有以下几种关系:泛化(Generalization),实现(Realization),关联(Association),聚合(Aggregation),组合(Composition),依赖(Dependency)1.泛化(Generalization)【泛化关系】:是一种继承关系... 阅读全文
posted @ 2015-04-15 11:12 穆穆兔兔 阅读(1240) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
posted @ 2015-04-14 13:26 穆穆兔兔 阅读(235) 评论(0) 推荐(0) 编辑
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文
posted @ 2015-04-13 16:47 穆穆兔兔 阅读(173) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文
posted @ 2015-04-13 16:12 穆穆兔兔 阅读(166) 评论(0) 推荐(0) 编辑
摘要:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文
posted @ 2015-04-13 11:28 穆穆兔兔 阅读(178) 评论(0) 推荐(0) 编辑
摘要:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]... 阅读全文
posted @ 2015-04-13 11:19 穆穆兔兔 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2015-04-10 17:04 穆穆兔兔 阅读(205) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2015-04-10 16:28 穆穆兔兔 阅读(193) 评论(0) 推荐(0) 编辑
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2015-04-10 14:26 穆穆兔兔 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2015-04-10 14:05 穆穆兔兔 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Ubuntu 下配置 Git 是一个快速、可扩展的分布式版本控制系统,它具有极为丰富的命令集,对内部系统提供了高级操作和完全访问。 一、Git安装: 1、 二进制方式安装: $ sudo apt-get install git-core 安装完成后,在终端中输入 git 就可以看到相关的命令了。如果 阅读全文
posted @ 2015-04-10 11:29 穆穆兔兔 阅读(323) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2015-04-10 10:48 穆穆兔兔 阅读(194) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2015-04-09 16:58 穆穆兔兔 阅读(193) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsDepth-first SearchLinked List方法一... 阅读全文
posted @ 2015-04-09 15:50 穆穆兔兔 阅读(211) 评论(0) 推荐(0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsTreeDepth-first Search方法一:递归,也是dfs/** * Defi... 阅读全文
posted @ 2015-04-09 15:31 穆穆兔兔 阅读(143) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-04-08 17:26 穆穆兔兔 阅读(226) 评论(0) 推荐(0) 编辑
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文
posted @ 2015-04-03 11:23 穆穆兔兔 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
posted @ 2015-04-02 17:15 穆穆兔兔 阅读(233) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-04-02 16:44 穆穆兔兔 阅读(182) 评论(0) 推荐(0) 编辑
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-04-02 16:02 穆穆兔兔 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
posted @ 2015-04-01 14:14 穆穆兔兔 阅读(177) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示