函数引用操作符

  1. struct absInt
  2. {
  3. int operator()(int val) const
  4. {
  5. cout<<val<<"<->!!!"<<endl;
  6. return val<0 ? -val : val;
  7. }
  8. };
  1. void fun1()
  2. {
  3. int i=-42;
  4. absInt absObj;
  5. int ui=absObj(i);
  6. }

Function-Object Classes with State

函数对象类的状态

  1. class PrintString
  2. {
  3. public:
  4. PrintString(ostream &o=cout, char c=' '):os(o), sep(c) {} //构造函数
  5. void operator()(const string &s) const {os<<">>>>-----<<<<"<<s<<sep<<"yeah!"<<endl;} //函数操纵符
  6. void operator()(const int i, const string &s1, const string &s2) const
  7. {
  8. if(i)
  9. {
  10. os<<"3 个參数 cutter_point-"<<s1<<endl;
  11. }
  12. else
  13. {
  14. os<<"3 个參数 cutter_point-"<<s2<<endl;
  15. }
  16. }
  17.  
  18. private:
  19. ostream &os; //输出流
  20. char sep;
  21. };
  22.  
  23. void fun2()
  24. {
  25. string s="cutter_point";
  26. PrintString printer; //默认构造函数
  27. printer(s); //调用操作符函数,输出:>>>>-----<<<<cutter_point yeah!
  28. PrintString errors(cerr, '\n'); //上面yeah!前面变成换行
  29. errors(s);
  30.  
  31. vector<string> vs;
  32. for(size_t i=0 ; i != 7 ; ++i)
  33. {
  34. stringstream ss;
  35. ss<<i<<"-cutter_point";
  36. vs.push_back(ss.str());
  37. }
  38. for_each(vs.begin(), vs.end(), PrintString(cerr, '\n'));
  39.  
  40. PrintString three;
  41. three(1, "我就是这么屌!", "没有,也就一般般啦!");
  42. }

14.8.1. Lambdas Are Function Objects

  1. void fun3()
  2. {
  3. vector<string> words;
  4. for(size_t i=0 ; i != 7 ; ++i)
  5. {
  6. stringstream ss;
  7. ss<<i<<"-cutter_point";
  8. words.push_back(ss.str());
  9. }
  10. stable_sort(words.begin(), words.end(), [](const string &a, const string &b){return a.size()<b.size();});
  11. for_each(words.begin(), words.end(), PrintString(cout, '3'));
  12. }
  13.  
  14. class ShorterString
  15. {
  16. public:
  17. bool operator()(const string &s1, const string &s2) const
  18. {return s1.size()<s2.size(); }
  19. };
  20.  
  21. void fun4()
  22. {
  23. vector<string> words;
  24. for(size_t i=8 ; i != -1 ; --i)
  25. {
  26. stringstream ss;
  27. ss<<i<<"-cutter_point";
  28. words.push_back(ss.str());
  29. }
  30. words.push_back("test排序");
  31.  
  32. stable_sort(words.begin(), words.end(), ShorterString());
  33. for(vector<string>::iterator it=words.begin() ; it != words.end() ; ++it)
  34. cout<<*it<<"\t";
  35. }

Classes Representing Lambdas with Captures

  1. void fun5()
  2. {
  3. vector<string> words;
  4. vector<string>::size_type sz=5;
  5. for(size_t i=8 ; i != -1 ; --i)
  6. {
  7. stringstream ss;
  8. ss<<i<<"-cutter_point";
  9. words.push_back(ss.str());
  10. }
  11. words.push_back("test排序");
  12.  
  13. //得到一个指向第一个s.size()>sz的元素
  14. auto wc=find_if(words.begin(), words.end(), [sz](const string &a){return a.size() >= sz;});
  15. for(vector<string>::iterator it=words.begin() ; it != words.end() ; ++it)
  16. cout<<*it<<"\t";
  17. if(wc != words.end())
  18. {
  19. cout<<"wc:"<<*wc<<endl;
  20. }
  21.  
  22. }
  23.  
  24. class SizeComp
  25. {
  26. public:
  27. SizeComp(size_t n):sz(n) {} //构造函数
  28. bool operator()(const string &s) const {return s.size()>=sz;}
  29. private:
  30. size_t sz;
  31. };
  32.  
  33. void fun6()
  34. {
  35. vector<string> words;
  36. vector<string>::size_type sz=6;
  37. for(size_t i=8 ; i != -1 ; --i)
  38. {
  39. stringstream ss;
  40. ss<<i<<"-cutter_point";
  41. words.push_back(ss.str());
  42. }
  43. words.push_back("test排序");
  44.  
  45. //得到一个指向第一个s.size()>sz的元素
  46. auto wc=find_if(words.begin(), words.end(), SizeComp(sz));
  47. ///这里为什么会引用operator()操作呢??
  48.  
  49. cout<<endl;
  50. if(wc != words.end())
  51. {
  52. cout<<"wc:"<<*wc<<endl;
  53. }
  54. }

14.8.2. Library-Defined Function Objects


  1. void fun7()
  2. {
  3. plus<int> intAdd; //这个是能够加两个int型数字
  4. negate<int> intNegate; //求相反数
  5. int sum=intAdd(10, 20); //结果30
  6. cout<<sum<<endl;
  7. sum=intNegate(intAdd(10, 20)); //结果-30
  8. cout<<sum<<endl;
  9. sum=intAdd(10, intNegate(10)); //结果0
  10. cout<<sum<<endl;
  11. }

Using a Library Function Object with the Algorithms
  1. void fun8()
  2. {
  3. vector<string> svec={"i","like","china","so","much","I","can","just","do","it"};
  4. //通过一个暂时的函数对象应用<操作对两个string
  5. sort(svec.begin(), svec.end(), greater<string>());
  6. //输出结果按字典位置排序,然后大写在后,递减排序
  7. for_each(svec.begin(), svec.end(), [](string &s){cout<<s<<"\t";});
  8. }

通过指针直接操作内存的地址,来改变排序

  1. void fun9()
  2. {
  3. vector<string> svec={"i","like","china","so","much","I","can","just","do","it"};
  4. vector<string*> nameTable;
  5. for(vector<string>::iterator it=svec.begin() ; it != svec.end() ; ++it)
  6. {
  7. string* s=new string; //这里new string一定要加!!,为了给s分配空间
  8. *s=*it;
  9. nameTable.push_back(s);
  10. }
  11.  
  12. // sort(nameTable.begin(), nameTable.end(), [](string* a, string* b){return a<b;});
  13. sort(nameTable.begin(), nameTable.end(), less<string*>());
  14. //输出的是按内存位置来输出的
  15. for(vector<string*>::iterator it=nameTable.begin() ; it != nameTable.end() ; ++it)
  16. cout<<*(*it)<<"\t";
  17. }

14.8.3. Callable Objects and function

可调用对象和函数


Different Types Can Have the Same Call Signature


  1. int add(int i, int j) {return i+j;}
  2. void fun10()
  3. {
  4. auto mod=[](int i, int j){return i%j;};
  5. }
  6. struct div2 //这里不要用div好像是和stdlib.h冲突了
  7. {
  8. int operator()(int denominator, int divisor){return denominator/divisor;}
  9. };
  10.  
  11. //上面三个都是int(int, int)类型的

我们能够定义一个map,用string类型来关联对应的函数,用string作为标识

  1. void fun11()
  2. {
  3. auto mod=[](int i, int j){return i%j;};
  4. map<string, int(*)(int, int)> binops; //这是一个函数指针,返回一个int类型
  5. //这里add是一个指向+运算的指针,div是不能这样加的,它不是指针
  6. binops.insert({"+", add});
  7. binops.insert({"%", mod});
  8. // binops.insert({"/", div2});
  9. }

库函数类型


  1. void fun12()
  2. {
  3. function<int(int, int)> f1=add; //函数指针,这个是加法
  4. function<int(int, int)> f2=div2(); //调用()操作符,这个是除法
  5. function<int(int, int)> f3=[](int i, int j) {return i*j;}; //lambda返回乘法
  6. cout<<f1(4,2)<<endl; //6
  7. cout<<f2(4,2)<<endl; //2
  8. cout<<f3(4,2)<<endl; //8
  9. }
  10.  
  11. void fun13()
  12. {
  13. auto mod=[](int i, int j){return i%j;};
  14. map<string, function<int(int, int)>> binops=
  15. {
  16. {"+", add},{"-", std::minus<int>()},{"/", div2()},{"*", [](int i, int j){return i*j;}},
  17. {"%", mod}
  18. }; //这个map有五个元素,当我们索引这个map的时候,我们能够调用这五个函数类型
  19.  
  20. cout<<"+ <--->"<<binops["+"](10, 5)<<endl;
  21. cout<<"- <--->"<<binops["-"](10, 5)<<endl;
  22. cout<<"/ <--->"<<binops["/"](10, 5)<<endl;
  23. cout<<"* <--->"<<binops["*"](10, 5)<<endl;
  24. cout<<"% <--->"<<binops["%"](10, 5)<<endl;
  25. }

Overloaded Functions and function

重载的函数和功能

  1. void fun14()
  2. {
  3. map<string, function<int(int, int)>> binops;
  4. int (*fp)(int, int)=add;
  5. binops.insert({"+", fp}); //用函数指针来避免重载,或者同名函数的含糊不清
  6. //含有一个非常好的办法就是使用lambda来消除歧义是非常好的
  7. binops.insert({"+", [](int a, int b){return add(a,b);}});
  8.  
  9. }

在新的库函数类是不相关的类命名为

unary_function和binary_function是较早的版本号的一部分

标准库。这些类被更一般的结合使用函数代替


全代码!


  1. /**
  2. * 功能:函数引用操作符
  3. * 时间:2014年7月18日16:11:45
  4. * 作者:cutter_point
  5. */
  6.  
  7. #include<iostream>
  8. #include<cstring>
  9. #include<vector>
  10. #include<algorithm>
  11. #include<sstream>
  12. #include<string>
  13. #include<map>
  14. #include<functional>
  15.  
  16. using namespace std;
  17.  
  18. struct absInt
  19. {
  20. int operator()(int val) const
  21. {
  22. cout<<val<<"<->!!!"<<endl;
  23. return val<0 ? -val : val;
  24. }
  25. };
  26.  
  27. void fun1()
  28. {
  29. int i=-42;
  30. absInt absObj;
  31. int ui=absObj(i);
  32. }
  33.  
  34. /**
  35. Function-Object Classes with State
  36. 函数对象类的状态
  37. */
  38. class PrintString
  39. {
  40. public:
  41. PrintString(ostream &o=cout, char c=' '):os(o), sep(c) {} //构造函数
  42. void operator()(const string &s) const {os<<">>>>-----<<<<"<<s<<sep<<"yeah!"<<endl;} //函数操纵符
  43. void operator()(const int i, const string &s1, const string &s2) const
  44. {
  45. if(i)
  46. {
  47. os<<"3 个參数 cutter_point-"<<s1<<endl;
  48. }
  49. else
  50. {
  51. os<<"3 个參数 cutter_point-"<<s2<<endl;
  52. }
  53. }
  54.  
  55. private:
  56. ostream &os; //输出流
  57. char sep;
  58. };
  59.  
  60. void fun2()
  61. {
  62. string s="cutter_point";
  63. PrintString printer; //默认构造函数
  64. printer(s); //调用操作符函数,输出:>>>>-----<<<<cutter_point yeah!
  65. PrintString errors(cerr, '\n'); //上面yeah!前面变成换行
  66. errors(s);
  67.  
  68. vector<string> vs;
  69. for(size_t i=0 ; i != 7 ; ++i)
  70. {
  71. stringstream ss;
  72. ss<<i<<"-cutter_point";
  73. vs.push_back(ss.str());
  74. }
  75. for_each(vs.begin(), vs.end(), PrintString(cerr, '\n'));
  76.  
  77. PrintString three;
  78. three(1, "我就是这么屌!", "没有,也就一般般啦!");
  79. }
  80.  
  81. /**
  82. 14.8.1. Lambdas Are Function Objects
  83. */
  84. void fun3()
  85. {
  86. vector<string> words;
  87. for(size_t i=0 ; i != 7 ; ++i)
  88. {
  89. stringstream ss;
  90. ss<<i<<"-cutter_point";
  91. words.push_back(ss.str());
  92. }
  93. stable_sort(words.begin(), words.end(), [](const string &a, const string &b){return a.size()<b.size();});
  94. for_each(words.begin(), words.end(), PrintString(cout, '3'));
  95. }
  96.  
  97. class ShorterString
  98. {
  99. public:
  100. bool operator()(const string &s1, const string &s2) const
  101. {return s1.size()<s2.size(); }
  102. };
  103.  
  104. void fun4()
  105. {
  106. vector<string> words;
  107. for(size_t i=8 ; i != -1 ; --i)
  108. {
  109. stringstream ss;
  110. ss<<i<<"-cutter_point";
  111. words.push_back(ss.str());
  112. }
  113. words.push_back("test排序");
  114.  
  115. stable_sort(words.begin(), words.end(), ShorterString());
  116. for(vector<string>::iterator it=words.begin() ; it != words.end() ; ++it)
  117. cout<<*it<<"\t";
  118. }
  119.  
  120. /**
  121. Classes Representing Lambdas with Captures
  122. */
  123. void fun5()
  124. {
  125. vector<string> words;
  126. vector<string>::size_type sz=5;
  127. for(size_t i=8 ; i != -1 ; --i)
  128. {
  129. stringstream ss;
  130. ss<<i<<"-cutter_point";
  131. words.push_back(ss.str());
  132. }
  133. words.push_back("test排序");
  134.  
  135. //得到一个指向第一个s.size()>sz的元素
  136. auto wc=find_if(words.begin(), words.end(), [sz](const string &a){return a.size() >= sz;});
  137. for(vector<string>::iterator it=words.begin() ; it != words.end() ; ++it)
  138. cout<<*it<<"\t";
  139. if(wc != words.end())
  140. {
  141. cout<<"wc:"<<*wc<<endl;
  142. }
  143.  
  144. }
  145.  
  146. class SizeComp
  147. {
  148. public:
  149. SizeComp(size_t n):sz(n) {} //构造函数
  150. bool operator()(const string &s) const {return s.size()>=sz;}
  151. private:
  152. size_t sz;
  153. };
  154.  
  155. void fun6()
  156. {
  157. vector<string> words;
  158. vector<string>::size_type sz=6;
  159. for(size_t i=8 ; i != -1 ; --i)
  160. {
  161. stringstream ss;
  162. ss<<i<<"-cutter_point";
  163. words.push_back(ss.str());
  164. }
  165. words.push_back("test排序");
  166.  
  167. //得到一个指向第一个s.size()>sz的元素
  168. auto wc=find_if(words.begin(), words.end(), SizeComp(sz));
  169. ///这里为什么会引用operator()操作呢??
  170.  
  171. cout<<endl;
  172. if(wc != words.end())
  173. {
  174. cout<<"wc:"<<*wc<<endl;
  175. }
  176. }
  177.  
  178. /**************************************
  179. 14.8.2. Library-Defined Function Objects
  180. **************************************/
  181. void fun7()
  182. {
  183. plus<int> intAdd; //这个是能够加两个int型数字
  184. negate<int> intNegate; //求相反数
  185. int sum=intAdd(10, 20); //结果30
  186. cout<<sum<<endl;
  187. sum=intNegate(intAdd(10, 20)); //结果-30
  188. cout<<sum<<endl;
  189. sum=intAdd(10, intNegate(10)); //结果0
  190. cout<<sum<<endl;
  191. }
  192.  
  193. /**************************************
  194. Using a Library Function Object with the Algorithms
  195. **************************************/
  196. void fun8()
  197. {
  198. vector<string> svec={"i","like","china","so","much","I","can","just","do","it"};
  199. //通过一个暂时的函数对象应用<操作对两个string
  200. sort(svec.begin(), svec.end(), greater<string>());
  201. //输出结果按字典位置排序,然后大写在后,递减排序
  202. for_each(svec.begin(), svec.end(), [](string &s){cout<<s<<"\t";});
  203. }
  204.  
  205. //通过指针直接操作内存的地址,来改变排序
  206. void fun9()
  207. {
  208. vector<string> svec={"i","like","china","so","much","I","can","just","do","it"};
  209. vector<string*> nameTable;
  210. for(vector<string>::iterator it=svec.begin() ; it != svec.end() ; ++it)
  211. {
  212. string* s=new string; //这里new string一定要加!!,为了给s分配空间
  213. *s=*it;
  214. nameTable.push_back(s);
  215. }
  216.  
  217. // sort(nameTable.begin(), nameTable.end(), [](string* a, string* b){return a<b;});
  218. sort(nameTable.begin(), nameTable.end(), less<string*>());
  219. //输出的是按内存位置来输出的
  220. for(vector<string*>::iterator it=nameTable.begin() ; it != nameTable.end() ; ++it)
  221. cout<<*(*it)<<"\t";
  222. }
  223.  
  224. /**************************************
  225. 14.8.3. Callable Objects and function
  226. 可调用对象和函数
  227. **************************************/
  228.  
  229. /**
  230. Different Types Can Have the Same Call Signature
  231. */
  232. int add(int i, int j) {return i+j;}
  233. void fun10()
  234. {
  235. auto mod=[](int i, int j){return i%j;};
  236. }
  237. struct div2 //这里不要用div好像是和stdlib.h冲突了
  238. {
  239. int operator()(int denominator, int divisor){return denominator/divisor;}
  240. };
  241.  
  242. //上面三个都是int(int, int)类型的
  243.  
  244. /*
  245. 我们能够定义一个map,用string类型来关联对应的函数,用string作为标识
  246. */
  247. void fun11()
  248. {
  249. auto mod=[](int i, int j){return i%j;};
  250. map<string, int(*)(int, int)> binops; //这是一个函数指针,返回一个int类型
  251. //这里add是一个指向+运算的指针,div是不能这样加的,它不是指针
  252. binops.insert({"+", add});
  253. binops.insert({"%", mod});
  254. // binops.insert({"/", div2});
  255. }
  256.  
  257. /**
  258. 库函数类型
  259. */
  260. void fun12()
  261. {
  262. function<int(int, int)> f1=add; //函数指针,这个是加法
  263. function<int(int, int)> f2=div2(); //调用()操作符,这个是除法
  264. function<int(int, int)> f3=[](int i, int j) {return i*j;}; //lambda返回乘法
  265. cout<<f1(4,2)<<endl; //6
  266. cout<<f2(4,2)<<endl; //2
  267. cout<<f3(4,2)<<endl; //8
  268. }
  269.  
  270. void fun13()
  271. {
  272. auto mod=[](int i, int j){return i%j;};
  273. map<string, function<int(int, int)>> binops=
  274. {
  275. {"+", add},{"-", std::minus<int>()},{"/", div2()},{"*", [](int i, int j){return i*j;}},
  276. {"%", mod}
  277. }; //这个map有五个元素,当我们索引这个map的时候,我们能够调用这五个函数类型
  278.  
  279. cout<<"+ <--->"<<binops["+"](10, 5)<<endl;
  280. cout<<"- <--->"<<binops["-"](10, 5)<<endl;
  281. cout<<"/ <--->"<<binops["/"](10, 5)<<endl;
  282. cout<<"* <--->"<<binops["*"](10, 5)<<endl;
  283. cout<<"% <--->"<<binops["%"](10, 5)<<endl;
  284. }
  285.  
  286. /**
  287. Overloaded Functions and function
  288. 重载的函数和功能
  289. */
  290. void fun14()
  291. {
  292. map<string, function<int(int, int)>> binops;
  293. int (*fp)(int, int)=add;
  294. binops.insert({"+", fp}); //用函数指针来避免重载,或者同名函数的含糊不清
  295. //含有一个非常好的办法就是使用lambda来消除歧义是非常好的
  296. binops.insert({"+", [](int a, int b){return add(a,b);}});
  297.  
  298. }
  299.  
  300. /*
  301. 在新的库函数类是不相关的类命名为
  302. unary_function和binary_function是较早的版本号的一部分
  303. 标准库。这些类被更一般的结合使用函数代替
  304. */
  305.  
  306. int main()
  307. {
  308. cout<<">>----------------fun1---------------------<<"<<endl;
  309. fun1();
  310. cout<<">>----------------fun2---------------------<<"<<endl;
  311. fun2();
  312. cout<<">>----------------fun3---------------------<<"<<endl;
  313. fun3();
  314. cout<<">>----------------fun4---------------------<<"<<endl;
  315. fun4();
  316. cout<<">>----------------fun5---------------------<<"<<endl;
  317. fun5();
  318. cout<<">>----------------fun6---------------------<<"<<endl;
  319. fun6();
  320. cout<<">>----------------fun7---------------------<<"<<endl;
  321. fun7();
  322. cout<<">>----------------fun8---------------------<<"<<endl;
  323. fun8();
  324. cout<<">>----------------fun9---------------------<<"<<endl;
  325. fun9();
  326. cout<<">>----------------fun12---------------------<<"<<endl;
  327. fun12();
  328. cout<<">>----------------fun13---------------------<<"<<endl;
  329. fun13();
  330.  
  331. system("pause");
  332. return 0;
  333. }

PS:今天早上有点晚了,不行,以后每天早上坚持至少8点開始,7点起床!!!努力,我要学的东西还非常多,远远不够,时间如此紧迫,怎可徒费光阴!!!

【足迹C++primer】48、函数引用操作符的更多相关文章

  1. 《C++ Primer》之重载操作符与转换(下)

    转换与类类型 可用一个实参调用的非 explicit 构造函数定义一个隐式转换.当提供了实参类型的对象而需要一个类类型的对象时,编译器将使用该转换.这种构造函数定义了到类类型的转换.除了定义到类类型的 ...

  2. [转] PostgreSQL学习手册(函数和操作符)

    一.逻辑操作符: 常用的逻辑操作符有:AND.OR和NOT.其语义与其它编程语言中的逻辑操作符完全相同. 二.比较操作符: 下面是PostgreSQL中提供的比较操作符列表: 操作符 描述 < ...

  3. 《C++ Primer》之重载操作符与转换(中)

    赋值操作符 类赋值操作符接受类类型形参,通常,该形参是对类类型的 const 引用,但也可以是类类型或对类类型的非 const 引用.如果没有定义这个操作符,则编译器将合成它.类赋值操作符必须是类的成 ...

  4. C++ Primer 有感(重载操作符)

    1.用于内置类型的操作符,其含义不能改变.也不能为任何内置类型定义额外的新的操作符.(重载操作符必须具有至少一个类类型或枚举类型的操作数.这条规则强制重载操作符不能重新定义用于内置类型对象的操作符的含 ...

  5. scala快速学习笔记(一):变量函数,操作符,基本类型

    为了用spark,先学下scala. 参考教程:http://meetfp.com/zh/scala-basic doc查询:http://docs.scala-lang.org 其它资料:http: ...

  6. PostgreSQL学习手册(五) 函数和操作符

    PostgreSQL学习手册(五) 函数和操作符 一.逻辑操作符:    常用的逻辑操作符有:AND.OR和NOT.其语义与其它编程语言中的逻辑操作符完全相同. 二.比较操作符:    下面是Post ...

  7. C++基础 (4) 第四天 this指针 全局函数和成员函数 友元 操作符重载

    1static强化练习-仓库进货和出货 #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; c ...

  8. Jmeter外部函数引用

    Jmeter外部函数引用 1.Beanshell引用Jmeter变量 添加用户自定义变量,输入变量名称和变量值,添加Debug sampler,用于输出初始变量值.

  9. PostgreSql字符串函数和操作符

    本节描述了用于检查和操作字符串数值的函数和操作符.在这个环境中的字符串包括所有 character, character varying, text 类型的值.除非另外说明,所有下面列出的函数都可以处 ...

随机推荐

  1. 命令行參数选项处理:getopt()及getopt_long()函数使用

         在执行某个程序的时候,我们通常使用命令行參数来进行配置其行为.命令行选项和參数控制 UNIX 程序,告知它们怎样动作. 当 gcc的程序启动代码调用我们的入口函数 main(int argc ...

  2. 【HDU】4888 Redraw Beautiful Drawings 网络流【推断解是否唯一】

    传送门:pid=4888">[HDU]4888 Redraw Beautiful Drawings 题目分析: 比赛的时候看出是个网络流,可是没有敲出来.各种反面样例推倒自己(究其原因 ...

  3. 成为JAVA软件开发工程师要学哪些东西

    2010-04-22 15:34 提问者采纳 Java EE(旧称j2ee)   第一阶段:Java基础,包括java语法,面向对象特征,常见API,集合框架: *第二阶段:java界面编程,包括AW ...

  4. OpenCV, color reduction method

    转载请注明出处!!!http://blog.csdn.net/zhonghuan1992 OpenCV, colorreduction method 目标: 这次学习的目标是回答以下的几个问题: 1 ...

  5. Web Worker在WebKit中的实现机制

    web worker 是执行在后台的 JavaScript,独立于其它脚本.不会影响页面的性能.这是HTML5的一个标准:实现上讲.浏览器为wokrer启动了新的线程,从而实现了异步操作的功能; 以下 ...

  6. C#中使用gRPC

    C#中使用gRPC 我的这几篇文章都是使用gRPC的example,不是直接编译example,而是新建一个项目,从添加依赖,编译example代码,执行example.这样做可以为我们创建自己的项目 ...

  7. mysql 触发器和存储过程组合使用,实现定时触发操作

    mysql可以实现定时触发功能,比如说定于某某时间mysql数据库做什么工作,或每隔多长时间做什么工作. 第二种情况应用还是比较广的,比如说我希望每天检查一下我的数据信息,超过一个月的无用信息清除以腾 ...

  8. 算法战斗:给定一个号码与通配符问号W,问号代表一个随机数字。 给定的整数,得到X,和W它具有相同的长度。 问:多少整数协议W的形式和的比率X大?

    如果说: 给定一个号码与通配符问号W,问号代表一个随机数字. 给定的整数,得到X,和W它具有相同的长度. 问:多少整数协议W的形式和的比率X大? 进格公式 数据的多组,两排各数据的,W,第二行是X.它 ...

  9. “AIR SDK 0.0: AIR SDK location “...\devsdks\AIRSDK\Win” does not exist.”问题解决~

    原文同步至:http://www.waylau.com/air-sdk-0-0-air-sdk-location-does-not-exist-address/ 导入AS3项目时提示“AIR SDK ...

  10. yum 简介及使用 安装、删除

    使用yum装软件很方便,这里简单介绍一下. Yum简介 Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE.CentOS中的She ...