- 博客(17)
- 收藏
- 关注
转载 The Liskov Substitution Principle
liscov替换原则(The Liskov Substitution Principle)子类型必须能够替换其基类型派生类必须能够通过其基类型的接口使用,客户端无需了解二者之间的差异
2019-06-25 00:42:45
317
原创 Exception的类别
Exception的类别Declare exceptions in a specificationDeclare exceptions in a specification“异常”也是方法和client端之间spec的一部分,在post-condition中刻画
2019-06-24 23:59:35
456
原创 面向性能优化的代码调优
面向性能优化的代码调优Common Sources of Inefficiency设计模式Singleton Pattern 单例模式Flyweight Pattern 轻量模式Prototype Pattern 原型模式代码调优不是为了修复bug,而是对正确的代码进行修改以提高其性能(时间空间复杂度)。通常是小规模的变化。Common Sources of InefficiencyO...
2019-06-24 21:52:19
639
原创 Java内存管理和垃圾回收
Java内存管理性能指标内存管理三种基本模式Static 静态Stack-based mode 动态,基于栈Heap-based mode(free mode) 动态,基于堆Java内存管理模型Java Virtual Machine (JVM)内存结构垃圾回收可达和不可达对象GC的成本指标四种算法Reference counting 引用计数Mark-Sweep 标记-清除Mark-Compac...
2019-06-24 20:20:44
625
原创 如何设计ADT
Designing an Abstract Type——Rules of thumb设计简洁、一致的操作要足以支持client对数据所做的所有操作需要,且用操作满足client需要的难度要低要么抽象、要么具体,不要混合 --- 要么针对抽象设计,要么针对具体应用的设计设计简洁、一致的操作简洁:操作要少而简单,不要多而复杂一致:不应该在List中增加sum操作,如果客户端使用的是List, 会...
2019-06-16 20:37:28
888
转载 图算法模板
dijkstra 堆优化 <转>#include <iostream> #include <cstdio> #include <queue> #include <vector> using namespace std; const int Ni = 10000; const int I...
2019-06-16 20:23:31
219
原创 ADT的四种操作
Classifying the operations of an abstract typeCreators构造器t* -> TProducers生产器T+, t* -> TObservers观察器T+, t* -> tMutators变值器T+, t* -> void | t | T四种方法的区别具体类型分析intStringList (extends Collecti...
2019-06-16 00:48:40
1045
原创 Designing Specification
Abstract Data Type -ADT- and ObjectOriented Programming -OOP-Designing SpecificationSpecification内容spec中不应出现什么Failing fast写出规约的原因行为等价性优点Designing Specification一个完整的方法包括两个方面方法的规约spec方法的实现体implemen...
2019-06-12 17:09:33
327
原创 Data Type and Type Checking
Abstract Data Type -ADT- and ObjectOriented Programming -OOP-Data Type and Type CheckingJava中的数据类型静态/动态类型检查可变/不变的数据类型可变数据类型的危险性 理解别名使用不变数据类型的优越性 Use immutability to improve correctness, clarity and ch...
2019-06-12 15:07:04
414
原创 monitor模式
设计模式monitor模式monitor模式监视器是一个方法相互排斥的类,因此一次只能有一个线程位于类的实例中.即用ADT自己做lock实现方法: 在所有方法内加上synchronized(this)或者synchronized形如public class XX { private String text; public XX() { text = ""; } ...
2019-06-05 13:28:12
2704
转载 hdu4004:二分:judge方法
The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over th...
2018-07-07 15:36:58
671
原创 归并排序+逆序对个数
void merge_sort(int* A,int x,int y,int* T){ if(y - x <= 1) return; int m = x + (y - x) / 2; //划分 merge_sort(A,x,m,T);merge_sort(A,m,y,T);//分别对子问题求解 int p = x, q = m,...
2018-05-24 23:26:36
255
转载 最大连续和问题 :1)分治法 2)DP
转你应该听说过分治法,正是:分而治之。我们有一个很复杂的大问题,很难直接解决它,但是我们发现可以把问题划分成子问题,如果子问题规模还是太大,并且它还可以继续划分,那就继续划分下去。直到这些子问题的规模已经很容易解决了,那么就把所有的子问题都解决,最后把所有的子问题合并,我们就得到复杂大问题的答案了。可能说起来简单,但是仍不知道怎么做,接下来分析这个问题:首先,我们可以把整个序列平均分成左右两部分,...
2018-05-24 22:41:17
586
原创 并查集:求到根结点的路径
A very big corporation is developing its corporative network. In the beginning each of the N enterprises of the corporation, numerated from 1 to N, organized its own computing and telecommunication ce...
2018-05-24 18:46:15
526
原创 数学基础问题
(一)最大公约数 gcd(a,b) 1、几何意义:两整点连线上的整点个数 2、两个或多个整数的共有约数中最大的一个 3、一条斜线段最多可分出多少个斜边,使平行与坐标轴的直角边为整数, 即最多分出多少个整直角边三角形 方法:辗转相除法:1)a = b * p + q the...
2018-04-30 00:27:27
260
原创 HDU 2066 单源最短路 朴素dijkstra
虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假...
2018-04-27 21:44:20
153
原创 POJ 3660任意两点之间的最短路 floyd裸题
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is un...
2018-04-27 20:54:21
413
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人