02 2011 档案

testing: mock object
摘要:- mock objecthttp://www.ibm.com/developerworks/library/j-mocktest.htmlMock Object Generate Tool 最开始,Mock Object是完全由测试者自己手工撰写的。这样,无可避免的会带来编写测试用例效率低下和测试用例编写困难的弊病,甚至可能会影响XP实践者“测试先行”的激情。此时,各种各样帮助创建Mock Object的工具就应运而生了。 这些工具中,有MockObjects、XDoclet等帮助程序员编写Mock Object实现的工具,也有EasyMock、MockCreator等自动创建Mock Ob 阅读全文

posted @ 2011-02-28 20:22 cutepig 阅读(331) 评论(0) 推荐(0) 编辑

alg_CLRS: graph DFS, topological sort
摘要:#include<stdio.h>#include<algorithm>#include<map>//DFSref:CLRS$22.3&22.4#defineMAX_VERTEX10intG[MAX_VERTEX][MAX_VERTEX]={0};intnVertex=0;#defineWHITE1#defineGRAY2#defineBLACK3intcolor[MAX_VERTEX]={0};intparent[MAX_VERTEX]={0};inttime=0;intd[MAX_VERTEX]={0};//startvisittimeforea 阅读全文

posted @ 2011-02-25 20:30 cutepig 阅读(294) 评论(0) 推荐(0) 编辑

What is the difference between data mining and machine learning?
摘要:http://www.google.com.hk/search?hl=zh-TW&client=firefox-a&hs=K3s&rls=org.mozilla%3Azh-TW%3Aofficial&q=difference+between+data+mining+and+machine+learning&aq=f&aqi=g1&aql=&oq= 阅读全文

posted @ 2011-02-25 11:01 cutepig 阅读(329) 评论(0) 推荐(0) 编辑

alg: why Quicksort superiority over Heap Sort
摘要:http://stackoverflow.com/questions/1853208/quicksort-superiority-over-heap-sorthttp://stackoverflow.com/questions/2467751/quicksort-vs-heapsort 阅读全文

posted @ 2011-02-25 11:00 cutepig 阅读(220) 评论(0) 推荐(0) 编辑

CLRS: union_find_sets
摘要://union_find_sets#include <assert.h>#include <stdio.h>#include <stdlib.h>#include <memory.h>//两个优化://1:rank数组的引入,启发式函数//2:路径压缩;//Abstract: UFSet //Author:Lifeng Wang (Fandywang)// Model One 与Model 2 路径压缩方式不同,合并标准不同const int MAXSIZE = 500010;int rank[MAXSIZE]; // 节点高度的上界int pa 阅读全文

posted @ 2011-02-23 20:27 cutepig 阅读(300) 评论(0) 推荐(0) 编辑

CLRS: heap sort and priority queue
摘要://ref: CLRS $6#include <stdio.h> #include <stdlib.h> #include <time.h> #include <assert.h> #include <algorithm> #define MAX 20int number[MAX+1];int heap_size;void printHeap(){ for(int i = 1; i <= heap_size; i++) { printf("%d ", number[i]); } printf("\n 阅读全文

posted @ 2011-02-22 20:46 cutepig 阅读(327) 评论(0) 推荐(0) 编辑

life: zz 关于爱情
摘要:发信人: BTpig (猪猡猡), 信区: Astrology标 题: 就说一个:喜欢对方的理由发信站: 水木社区 (Wed Feb 16 10:40:38 2011), 站内昨晚看电视,幸福魔方《她大我16岁》相差16岁的爱情,女方明显的非常成熟,性格也不错,尤其说话的时候淡定平和的语调,很喜欢想起来我喜欢巨蟹的一个理由:我若情绪不好或心中有怒的时候,说话像利刀,很不留情面;且语气很激动,看上去就一副怒不可遏的状态;巨蟹纵使心里有再多怨怒,语气还是平和的,看上去也风平浪静许多我喜欢、欣赏并想拥有这份淡定从容;希望是表面+内心的发信人: biteshark (你带走了我的魂), 信区: Pie 阅读全文

posted @ 2011-02-17 23:36 cutepig 阅读(332) 评论(0) 推荐(0) 编辑

Atl: COM IDispatch interface client
摘要:#include <atlstr.h> //CStringint _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); CComPtr<IDispatch> m_pFSO; CComVariant strFolder(_T("C:\\11111") ); LPCOLESTR lpszName = L"CreateFolder"; m_pFSO.CoCreateInstance ( L"Scripting.FileSystemObject" );#if 1 HRESULT hRes = m_pFSO.Invoke1 阅读全文

posted @ 2011-02-17 15:19 cutepig 阅读(305) 评论(0) 推荐(0) 编辑

c++: lazy evaluation
摘要:#include <vector>#include <assert.h>struct Expression;struct Num{ Num(size_t n, int i) { data.resize(n, i); } Num& operator=(Expression& exp); void print() const { for(size_t i=0; i<data.size();i++) printf("%d ", data); printf("\n"); } std::vector <int> data;};stru 阅读全文

posted @ 2011-02-17 15:13 cutepig 阅读(380) 评论(0) 推荐(0) 编辑

c++: simple signal lib
摘要://typedef function0 <int> FunctionType;#include <iostream>#include <boost/shared_ptr.hpp>#include <vector>#include <algorithm>using namespace boost;using namespace std;typedef int RType;typedef RType (*FunctionType)();class MySlot{public: bool IsValid() {return fun_!=0; 阅读全文

posted @ 2011-02-17 14:26 cutepig 阅读(361) 评论(0) 推荐(0) 编辑

tool: count line count of files in a folder
摘要:#include <stdio.h>#include <windows.h>//#include <hash_map>//#include <string>char line[10000];FILE *fpW = 0; //count lineFILE *fpW_Date = 0; //for srch file within some datelong gnchar=0,gnline=0;int hours_before = 0;char destFolder[MAX_PATH]={0};//std::hash_map<std::st 阅读全文

posted @ 2011-02-17 14:23 cutepig 阅读(419) 评论(0) 推荐(0) 编辑

alg_DP: LCS ( longest common substring )
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>//Run By LCS.// O (m*n)// DP implementationconst char* GetSameString (char const* ArgA,char const* ArgB, int *pN){int nA = strlen(ArgA);int nB = strlen(ArgB);if (!nA || !nB) return 0;int* CompareArr=new int[nB];int max=0,maxJ= 阅读全文

posted @ 2011-02-17 14:22 cutepig 阅读(248) 评论(0) 推荐(0) 编辑

c: investigate float
摘要:#include <stdio.h>#include <math.h>#include <assert.h>double f(int x){ return 1.0/x;}void Test1(){ double a,b; int i; a=f(10); b=f(10); i = a==b; printf("%d\n", i);}void Test2(){ double a,b,c; int i; a=f(10); b=f(10); c=f(10); i = a==b; printf("%d\n", i);}template <typename T> 阅读全文

posted @ 2011-02-17 14:19 cutepig 阅读(282) 评论(0) 推荐(0) 编辑

alg: atof
摘要:#include <stdio.h>#include <math.h>int Reverse(int n){ int m=0; for( ; n>0; n/=10 ) m = m*10 + (n%10); return m;}bool IsNumber(char c){ return c>='0' && c<='9';}double Atof(const char *s, char **stopPos){ int sign = 1; double l1 = 0.0; double l2 = 0.0; int sign2 = 1; do 阅读全文

posted @ 2011-02-17 14:17 cutepig 阅读(219) 评论(0) 推荐(0) 编辑

C++: RVO( return value optimization)
摘要:#include <stdio.h>class RVO{public: RVO() { printf("I am in constructor %d\n", this); } RVO (const RVO& c_RVO) { printf ("I am in copy constructor %d\n", this); } ~RVO() { printf ("I am in destructor %d\n", this); } RVO& operator=(const RVO& rhs) { printf ("I am in operator %d = %d 阅读全文

posted @ 2011-02-17 14:16 cutepig 阅读(3285) 评论(0) 推荐(0) 编辑

alg: replace the substring
摘要:#include <string>#include <iostream>//replace the substring l to r for source string s, and put result in dvoid replace(const std::string& s,const std::string& l,const std::string& r,std::string& d){ size_t i=0, n=s.length(), nl=l.length(); while( 1 ) { size_t pos = s.f 阅读全文

posted @ 2011-02-17 14:15 cutepig 阅读(329) 评论(0) 推荐(0) 编辑

C++: Ctor
摘要:// A: // no default ctor// with copy ctorclass A{public: explicit A(int) {}};//B:// no default ctor// no ctor from int// with copy ctorclass B: public A{};int main(){ //A a; //fail A a(1); //ok A a2(a); //ok //B b(1); //fail //B b; //fail B *pb = (B*)0; B b(*pb); //OK} 阅读全文

posted @ 2011-02-17 14:12 cutepig 阅读(474) 评论(0) 推荐(0) 编辑

C++: TypeList
摘要:#include <stdio.h>#include <typeinfo.h>//// TypeList//template <class T, class U>struct TypeList{ typedef T Head; typedef U Tail;};struct NullType{};#define TYPELIST_1(T1) TypeList<T1, NullType>#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2) >#define TYPELIST_3( 阅读全文

posted @ 2011-02-17 14:09 cutepig 阅读(1487) 评论(0) 推荐(0) 编辑

alg_trie: count Word frequency
摘要:#include <stdio.h>#include <stdlib.h>#include <string.h>#define TREE_WIDTH 256#define WORDLENMAX 128// count Word frequencystruct trie_node_st { int count; struct trie_node_st *next[TREE_WIDTH];};static struct trie_node_st root={0, {NULL}};static char *spaces=" \t\n/.\"\'()";static 阅读全文

posted @ 2011-02-17 14:08 cutepig 阅读(301) 评论(0) 推荐(0) 编辑

alg: 反转字符串中的单词顺序
摘要:#include <stdio.h>//2. 反转字符串或反转段落中的单词顺序;void reverse(const char *s, //source string int n, //length of s char *d) //destination{ int i=n-1; int di=0; while(i>=0) { //find a word int si=i; for(; si>=0; i--) { if(s[si]==' ') break; } //copy to d for(int j=si; j<=i; j++) d[di++] 阅读全文

posted @ 2011-02-17 14:04 cutepig 阅读(313) 评论(0) 推荐(0) 编辑

alg: 首尾相连的珠子
摘要:#include <stdio.h>/*感觉稍微难点的三个:1)设计一个栈结构,满足一下条件:min,push,pop操作的时间复杂度为O(1)3)设计一个系统处理词语搭配问题,比如说 中国 和人民可以搭配,则中国人民 人民中国都有效。要求: 1)系统每秒的查询数量可能上千次; 2)词语的数量级为10W; 3)每个词至多可以与1W个词搭配 当用户输入中国人民的时候,要求返回与这个搭配词组相关的信息.*//*2)一串首尾相连的珠子(m个),有N种颜色(N《=10),设计一个算法,取出其中一段,要求包含所有N中颜色,并使长度最短。并分析时间复杂度与空间复杂度。time: O(m)spa 阅读全文

posted @ 2011-02-17 14:01 cutepig 阅读(1456) 评论(1) 推荐(0) 编辑

C++: Impl of RTTI
摘要:#include <stdio.h>#define CHECK(x) {if(!(x)) printf("ERROR " #x " @Line %d\n", __LINE__);}struct TypeInfo{ char* m_name; const TypeInfo* m_parent; TypeInfo(char* name, const TypeInfo* parent) :m_name(name), m_parent(parent) { }};class A{ static TypeInfo typeInfo_a;public: static const TypeInf 阅读全文

posted @ 2011-02-17 13:57 cutepig 阅读(1099) 评论(0) 推荐(0) 编辑

alg_problem: number_of_disc_intersections
摘要:Given an array A of N integers we draw N discs in a 2D plane, such that i-th disc has center in (0,i) and a radius A[i]. We say that k-th disc and j-th disc intersect, if and k-th and j-th discs have at least one common point. Write a function int number_of_disc_intersections(int[] A); which giv 阅读全文

posted @ 2011-02-17 12:14 cutepig 阅读(570) 评论(1) 推荐(0) 编辑

C++: public/protected/private inheritance
摘要:class A{ public: int a; private: int b; protected: int c;};// // public inheritance:// - data access type not change// - B cannot access A's private member//class B: public A{ public: void test() { a = 1; //b = 1; //Fail c = 1; }};// // protected inheritance:// - data access type: public -&g 阅读全文

posted @ 2011-02-17 12:12 cutepig 阅读(791) 评论(0) 推荐(0) 编辑

C++: member function pointer for SomeClass
摘要:#include <stdio.h>class SomeClass {public: void some_member_func(int x, char *p) { printf("In SomeClass"); };};class DerivedClass : public SomeClass {public:// If you uncomment the next line, the code at line (*) will fail!// void some_member_func(int x, char *p) { printf("In DerivedClass"); 阅读全文

posted @ 2011-02-17 12:10 cutepig 阅读(244) 评论(0) 推荐(0) 编辑

ML近三年在CVPR比较流行被应用的技术有哪些?
摘要:发信人: mlmonster (bishop), 信区: AI标 题: ML近三年在CVPR比较流行被应用的技术有哪些?发信站: 水木社区 (Sun Feb 13 01:31:10 2011), 站内是不是以下几个:nonparametric bayesian/LDA structure learning of graphical modelsparse representation/compressive sensinggaussian processmanifold learning请大家各抒己见,说说自己觉得比较有应用前景的技术吧?发信人: mlmonster (bishop), 信区: 阅读全文

posted @ 2011-02-17 08:16 cutepig 阅读(434) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示