定义 迭代器模式(Iterator
Pattern)提供一种方法访问一个容器对象中各个元素,而又不需暴露该对象内部细节。 迭代器模式通用类图 Iterator抽象迭代器
抽象迭代器负责定义访问和遍历元素的接口,而且基本上是有固定的3个方法:First()获取第一个元素,Next()访问下一个元素,I...
分类:
其他好文 时间:
2014-06-09 20:55:24
阅读次数:
316
psutil是python的一个用于获取cpu信息的模块,非常好使,以下附上官方的一些example:
CPU-> Examples>>> import psutil>>>
psutil.cpu_times()scputimes(user=3961.46, nice=169.729, syst...
分类:
其他好文 时间:
2014-06-09 19:36:32
阅读次数:
418
原题地址:https://oj.leetcode.com/problems/simplify-path/题意:Given
an absolute path for a file (Unix-style), simplify it.For example,path="/home/",
=>"/home...
分类:
编程语言 时间:
2014-06-09 19:13:54
阅读次数:
181
Map-reduce是一种优雅的数据处理方式,本文通过三个例子介绍如何用python在linux的管道进行map-reduce编程,本文写的所有map-reduce程序都可以原封不动的放在Hadoop下运行,很容易在大数据集上扩展。
分类:
其他好文 时间:
2014-06-09 19:11:44
阅读次数:
253
原题地址:https://oj.leetcode.com/problems/scramble-string/题意:Given
a strings1, we may represent it as a binary tree by partitioning it to two
non-empty su...
分类:
编程语言 时间:
2014-06-09 19:02:59
阅读次数:
197
1. python -m cProfile myprogram.py2. 使用import
profile模块import profiledef profileTest(): ...if __name__ == "__main__":
profile.run("profileTest()")3......
分类:
编程语言 时间:
2014-06-09 18:59:10
阅读次数:
219
原题地址:https://oj.leetcode.com/problems/search-in-rotated-sorted-array/题意:Suppose
a sorted array is rotated at some pivot unknown to you beforehand.(i.e...
分类:
编程语言 时间:
2014-06-09 18:43:14
阅读次数:
273
关于数据结构与算法讲解的书籍很多,但是用python语言去实现的不是很多,最近有幸看到一本这样的书籍,由Brad Miller and David
Ranum编写的《Problem Solving with Algorithms and Data Structures Using Python》.....
分类:
编程语言 时间:
2014-06-09 16:16:53
阅读次数:
276
迭代器模式:提供一个方法顺序访问一个聚合对象中各个元素,而又不暴露该对象的内部表示简单描述:提供一个单独的接口遍历聚集类对象中的成员,以实现聚集对象的隐藏和内部数据供外部访问大话设计模式中的截图:我觉得以上面的图示进行编码会暴露ConcreteAggregate中的内部信息(ConcreteIera...
分类:
编程语言 时间:
2014-06-09 15:28:57
阅读次数:
314
行为类模式包括责任链模式、命令模式、解释器模式、迭代器模式、中介者模式、备忘录模式、观察者模式、状态模式、策略模式、模板方法、访问者模式,我去,好多。。。下面主要挑选几个比较容易混淆且比较重要的模式进行对比说明。一、命令模式VS策略模式1、关注点不同策略模式关注的是算法替换的问题:一个新的算法投产,...
分类:
其他好文 时间:
2014-06-09 13:01:50
阅读次数:
236