python中的装饰器可以装饰函数,也可以装饰类,功能是向函数或者类添加一些功能。类似于设计模式中的装饰模式,它可以把装饰器的功能实现部分和装饰部分分开,避免类中或者函数中冗余的代码。
装饰器装饰函数:
def decrator(f1):
def newf():
print "strings will be connected:"
print f1();
return newf;...
分类:
编程语言 时间:
2014-07-28 00:21:15
阅读次数:
299
用优先队列实现
模板:
struct node
{
int pos, dist;
friend bool operator b.dist;
}
};
int Dijkstra(int n,int start,int end)
{
bool visited[maxn]...
分类:
其他好文 时间:
2014-07-28 00:07:00
阅读次数:
305
Palindrome Partitioning II
Total Accepted: 11791 Total
Submissions: 66110My Submissions
Given a string s, partition s such that every substring of the partition is a palindrome.
Return t...
分类:
其他好文 时间:
2014-07-27 23:59:19
阅读次数:
592
先建立一个table的基类:
public abstract class DbBaseTable {
private static final String TAG = "DbBaseTable";
/**
* @return the DB table name
*/
abstract String getName();
/**
* Creates the DB table ...
分类:
移动开发 时间:
2014-07-27 23:54:19
阅读次数:
478
在基类的table中加入upgrade操作:
public abstract class DbBaseTable {
private static final String TAG = "DbBaseTable";
/**
* @return the DB table name
*/
abstract String getName();
/**
* Creates th...
分类:
移动开发 时间:
2014-07-27 23:52:19
阅读次数:
387
LeetCode: Reverse Words in a StringGiven an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky...
分类:
其他好文 时间:
2014-07-27 23:33:19
阅读次数:
173
并查集简单题#include #include using namespace std;#define max 30010int f[max];int getf(int k){ while(k!=f[k]){ k=f[k]; } return k;}void combine(int a,int b)...
分类:
其他好文 时间:
2014-07-27 23:31:09
阅读次数:
193
class Solution {private: vector res;public: vector generateTrees(int n) { res.clear(); res = dfs(1, n + 1); return res; ...
分类:
其他好文 时间:
2014-07-27 23:28:19
阅读次数:
195
#include #include 考查了对next数组的了解using namespace std;#define max 1000005int next[max],l,ans[max];char s[max];void getNext(){ int j,k; next[0]=-1; j=0;k=...
分类:
其他好文 时间:
2014-07-27 23:26:49
阅读次数:
174
第一题并查集纪念#include using namespace std;int f[1010];int getf(int k){ while(k!=f[k]){ k=f[k]; } return k;}void combine(int a,int b){ in...
分类:
其他好文 时间:
2014-07-27 23:22:39
阅读次数:
212