《RFC6388》部分理解翻译

3. Setting up MP2MP LSPs with LDP

An MP2MP LSP is much like a P2MP LSP in that it consists of a single root node, zero or more transit nodes, and one or more Leaf LSRs acting equally an as Ingress or Egress LSR.

Leer más

Java设计模式

工厂模式

简单工厂模式

简单工厂模式(Simple Factory Pattern):定义一个工厂类,它可以根据参数的不同返回不同类的实例,被创建的实例通常都具有共同的父类。因为在简单工厂模式中用于创建实例的方法是静态(static)方法,因此简单工厂模式又被称为静态工厂方法(Static Factory Method)模式,它属于类创建型模式。

Leer más

《Effective Java》整理

Part1:创建和销毁对象

第1条:考虑用静态工厂方法代替构造器

第2条:遇到多个构造器参数时要考虑用构建器

第3条:用私有构造器或者枚举类型强化Singleton属性

声明一个私有构造方法覆盖默认的公有构造方法使得无法通过new来构造单例对象,而外部仅能通过一个公有的静态方法来获取单例类对象的引用。

Leer más

Java面试点

1.“static”关键字是什么意思?Java中是否可以覆盖(override)一个private或者是static的方法?

Leer más

C++中local static对象与non-local static对象的概念与区别

C++中local static对象与non-local static对象的概念与区别

C++中的static对象是指存储区不属于stack和heap、”寿命”从被构造出来直至程序结束为止的对象。这些对象包括全局对象,定义于namespace作用域的对象,在class、function以及file作用域中被声明为static的对象。其中,函数内的static对象称为local static 对象,而其它static对象称为non-local static对象。

Leer más

《Effective C++》整理

条款2:尽量以const,enmu,inline替换#define

1.使用#define的缺点1:#define的原理是替换,也就是属于编辑范畴。程序开发者无法直接看到编辑后的代码,因此当#define替换引起编译错误时可能会给开发者带来困惑,如果#define定义的位置在其它人写的文件中,那就更让人摸不着头脑了。

Leer más

数据库基础概念

关系模型部分

1.关系数据库由表(table)的集合组成。

Leer más

排序算法经典实现

快速排序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int Partition(vector<int>& v, int low, int high)
{
int pivotkey = v[low];
while(low < high)
{
while(low < high && v[high] >= pivotkey) --high;
swapint(v[low], v[high]);
while(low < high && v[low] <= pivotkey) ++low;
swapint(v[low], v[high]);
}
return low;
}
void Qsort(vector<int>& v, int low, int high)
{
if(low >= high) return;
int pivotloc = Partition(v, low, high);
Qsort(v, low, pivotloc - 1);
Qsort(v, pivotloc + 1, high);
}
//调用方式:Qsort(vec, 0, vec.size());

Leer más

LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal

Description

Given preorder and inorder traversal of a tree, construct the binary tree.

Leer más

LeetCode 142. Linked List Cycle II

Description

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.

Leer más