首页 文章 精选 留言 我的

精选列表

搜索[JavaScript库],共10000篇文章
优秀的个人博客,低调大师

DWS和各异构数据库的差异对比

类型名称 DWS建表类型 Impala建表类型2字节整数 SMALLINT SMALLINT4字节整数 INTEGER INT8字节整数 BIGINT BIGINT单精度浮点数 FLOAT4 (REAL) FLOAT双精度浮点型 FLOAT8(DOUBLE PRECISION) DOUBLE科学数据类型 DECIMAL[p (,s)] 最大支持38位精度 DECIMAL最大支持38位(HIVE 0.11)日期类型 DATE DATE时间类型 TIMESTAMP TIMESTAMPBoolean类型 BOOLEAN BOOLEANChar类型 CHAR(n) CHAR (n)VarChar类型 VARCHAR(n) VARCHAR (n)字符串(文本大对象) TEXT(CLOB) STRING

优秀的个人博客,低调大师

其实它是个Python库

今天,谷歌联合Columbia University、Adobe(就是你们知道的那个Adobe)提出深度概率编程语言Edward,我就其发布Edward的专业论文,给大家介绍一下,这个秒天秒地秒空气的牛逼哄哄的新语言(框架)。 为什么开发Edward? 因为现在的概率编程语言啊, Too Young!Too Simple! 原文是这样的: Rather, most existing probabilistic programming languages treat the inference engine as a black box,abstracted away from the model. These cannot capture the recent advances in probabilistic inference that

优秀的个人博客,低调大师

标准模板库(STL)学习指南之set集合

set是关联容器。其键值就是实值,实值就是键值,不可以有重复,所以我们不能通过set的迭代器来改变set的元素的值,set拥有和list相同的特性:当对他进行插入和删除操作的时候,操作之前的迭代器依然有效。当然删除了的那个就没效了。set的底层结构是RB-tree,所以是有序的。 stl中特别提供了一种针对set的操作的算法:交集set_intersection,并集set_union,差集set_difference。对称差集set_symeetric_difference,这些算法稍后会讲到。 一:set模板类的声明。 template < class key class =Traitsless<key> class Allocator=allocator<key> > class set。 其中个参数的意义如下: key:要放入set里的数据类型,可以是任何类型的数据。 Traits:这是一个仿函数(关于仿函数是什么,我后面的文章会讲到)。提供了具有比较功能的仿函数,来觉得元素在set里的排列的顺序,这是一个可选的参数,默认的是std::less<key>,如果要自己提供这个参数,那么必须要遵循此规则:具有两个参数,返回类型为bool。 Allocator:空间配置器,这个参数是可选的,默认的是std::allocator<key>. 二:set里的基本操作 我们可以通过下面的方法来实例化一个set对象 std::set<int> s;那个s这个对象里面存贮的元素是从小到大排序的,(因为用std::less作为比较工具。) 如果要想在s里面插入数据,可以用inset函数(set没用重载[]操作,因为set本生的值和索引是相同的) s.insert(3);s.insert(5)..... 因为set是集合,那么集合本身就要求是唯一性,所以如果要像set里面插入数据和以前的数据有重合,那么插入不成功。 可以通过下面的方法来遍历set里面的元素 1 2 3 4 5 std::set< int >::iterator it = s.begin(); while (it!=s.end()) { cout<<*it++<<endl; //迭代器依次后移,直到末尾。 } 如果要查找一个元素用find函数,it = s.find(3);这样it是指向3的那个元素的。可以通过rbegin,rend来逆向遍历 1 2 3 4 5 std::set< int >::reverse_iterator it = s.rbegin(); while (it!=s.rend()) { cout<<*it++<<endl; } 还有其他的一些操作在这就不一一列出了。 三:set向量的使用实例 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 #include <iostream> #include <string> #include <set> #include <algorithm> #include <iterator> using namespace std; /* 联合容器将值与关键字联合在一起,使用关键字来查找值, * 提供元素的快速访问,插入元素不能指定位置,容器自动处理插入位置 * STL 提供四种联合容器:set、multiset、map、multimap * set、multiset 存储一种元素,前者关键字不可重复,后者关键字可以重复。 * map、multimap 存储一对元素键与值,前者关键字不可重复,后者关键字可以重复。 */ int main() { const int N = 3; string s1[N] = { "xp" , "python" , "linux" }; string s2[N] = { "python" , "php" , "perl" }; set<string> sa(s1, s1 + N); // 声明一个集合sa,元素为数组s1 set<string> sb(s2, s2 + N); // 声明一个集合sb,元素为数组s2 set<string> sc; // 声明一个空集合sc ostream_iterator<string, char > out (cout, " " ); copy(sa.begin(), sa.end(), out); cout << "->set sa" << endl; copy(sb.begin(), sb.end(), out); cout << "->set sb" << endl; set_union(sa.begin(), sa.end(), sb.begin(), sb.end(), out); cout << "->set_union() 并集" << endl; set_intersection(sa.begin(), sa.end(), sb.begin(), sb.end(), out); cout << "->set_intersection() 交集" << endl; set_difference(sa.begin(), sa.end(), sb.begin(), sb.end(), out); cout << "->set_difference() 集合的差" << endl; set_difference(sb.begin(), sb.end(), sa.begin(), sa.end(), out); cout << "->set_difference() 集合的差" << endl; set_union(sa.begin(), sa.end(), sb.begin(), sb.end(), insert_iterator<set<string> >(sc, sc.begin() )); sc.insert( "delphi" ); copy(sc.begin(), sc.end(), out); cout << "->set sc" << endl; copy(sc.lower_bound( "perl" ), sc.upper_bound( "python" ), out); cout << "->显示集合区间" << endl; return 0; } 作者:ACShiryu出处:http://www.cnblogs.com/ACShiryu/若非注明,本博客文章均为原创,版权归作者和博客园共有,欢迎转载,但必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。该文章也同步发布在我的新浪微博中-ACShiryu's weibo,欢迎收听。

优秀的个人博客,低调大师

《C++标准程序库》读书笔记(三)

STL中的智能指针auto_ptr可以实现简单的内存自动回收,防止内存泄漏(memory leakage)。auto_ptr实际是一个类,在该类析构时自动调用delete,从而达到了内存回收的效果。但是,由于同一个指针同一时刻只能被一个auto_ptr占用,如果采用赋值操作(=)或者拷贝构造函数调用,就会发生所有权转移,例如: auto_ptr<int> p(new int(0)); auto_ptr<int> q; 此时,p拥有指向一个int的指针,q的指针为空。如果执行q=p;则,p指向空,q指向int;但是,这样所有权转换的问题同样发生在参数传递中,例如 void foo(auto_ptr<int> t); 如果调用 foo(p);那么p就丢失了指针,所以一个解决方法是用引用,例如: void foo1(auto_ptr<int>& t); void foo2 (const auto_ptr<int>& t); 两者都是可以的,不过foo1非常不安全,因为在函数里面很容易通过类似赋值的操作使t丢失指针,而foo2不会。例如 void foo2(const auto_ptr<int>& t) { auto_ptr<int> m; m=t; } 会发生编译错误,从而避免灾难的发生。但随之又出现一个很大的问题,就是auto_ptr类的拷贝构造函数,或者赋值函数。最理想的情况是这样(如果能成功,就不会有别的什么问题): auto_ptr(const auto_ptr& rhs):ap(rhs.release()){} 但由于上述的原因,会发生编译错误(因为调用了release(),而release()会改变成员变量,不再是const)。所以只能去掉const,变为 auto_ptr(auto_ptr& rhs):ap(rhs.release()){} 这样可以编译成功,而且往往也能正确运行,但是唯一的问题是: 当rhs为右值时会出现问题。 为了简化问题,先假设拷贝构造函数什么都不做,即: auto_ptr(auto_ptr& rhs){} 那么,如果有 auto_ptr<int> p(new int(10)),执行 auto_ptr<int> q(p),不会有任何问题,因为p是左值。但如果执行auto_ptr<int> q(auto_ptr<int>(new int(10))) ,则会发生编译错误,因为auto_ptr<int>(new int(10)) 是右值,对右值的引用只能是常引用,也就是"const auto_ptr& rhs"的形式。但这里要注意的是,刚才那段代码用VC编译没有任何问题,并且可以顺利运行,但是用GCC之类的标准c++就不能顺利编译。 在VC中auto_ptr<int>& p=auto_ptr<int>(new int(0)) 是合法的,但在标准C++中是不合法的,只有const auto_ptr<int>& p=auto_ptr<int>(new int(0)) 才是合法的,也即在标准C++中,对右值的引用只能是常引用。所以说,要在标准C++中实现 auto_ptr<int> p(auto_ptr<int>(new int(0))) 就变得不可能了,因为如上所说,拷贝构造函数是这样的形式:auto_ptr(auto_ptr<T>& rhs):ap(rhs.release()){} 但是不能把右值传到一个非常引用中。但毕竟有聪明的人能想到解决办法,利用代理类( proxy class)声明如下结构,为了方便,我用int代替模板参 struct auto_ptr_ref { int* p; auto_ptr_ref(int *t):p(t){} }; 然后在auto_ptr类中增加了以下函数 auto_ptr(auto_ptr_ref rhs):ap(rhs.p){} auto_ptr& operator=(auto_ptr_ref rhs){reset(rhs.p); return *this;} operator auto_ptr_ref(){return auto_ptr_ref(release());} 之后,如果在标准C++有以下调用(VC中也会按照这个步骤调用,虽然没有auto_ptr_ref它也能直接调用) auto_ptr<int> p(auto_ptr<int>(new int(0))) 便可以成功,过程如下: 1. 构造临时对象 auto_ptr<int>(new int(0)) 2. 想将临时对象通过拷贝构造函数传给p,却发现没有合适的拷贝构造函数,因为只有auto_ptr(auto_ptr& rhs)这个不能用,又没有auto_ptr(const auto_ptr& rhs) (因为用了在所有权转移中会出错)! 3. 编译器只能曲线救国,看看类型转换后能不能传递。 4. 由于我们定义了 operator auto_ptr_ref() 所以编译器自然就可以试一下转为 auto_ptr_ref类型。 5. 编译器猛然间发现,我们定义了 auto_ptr(auto_ptr_ref rhs):ap(rhs.p){} 的构造函数,可以传递。 6. 顺利构造p,任务完成。 其实说白了问题很简单,因为构造函数不能接受右值,则取中间左值=右值, 然后再让函数接受中间左值。 而这一系列过程正是利用编译器能够自动进行类型转换而完成的。 本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/08/19/1271700.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

《C++标准程序库》读书笔记(四)

, 复制代码 #include <iostream> #include <list> #include <algorithm> using namespace std; int main() { list<int> coll; list<int>::iterator pos25,pos35,pos; for(int i=20;i<=40;++i) coll.push_back(i); pos25 = find(coll.begin(),coll.end(),25); pos35 = find(coll.begin(),pos25,35); if(pos35!=pos25) {//pos35在pos25前 pos = find(coll.begin(),pos25,30); } else {//pos25在pos35前 pos = find(pos25,coll.end(),30); } cout<<"num: "<<*pos<<endl; system("pause"); return 0; } 复制代码 使用仿函数 复制代码 #include <functional> /* class for the compose_f_gx_hx adapter*/ template <class OP1, class OP2, class OP3> class compose_f_gx_hx_t : public std::unary_function<typename OP2::argument_type, typename OP1::result_type> { private: OP1 op1; // process: op1(op2(x),op3(x)) OP2 op2; OP3 op3; public: // constructor compose_f_gx_hx_t (const OP1& o1, const OP2& o2, const OP3& o3) : op1(o1), op2(o2), op3(o3) { } // function call typename OP1::result_type operator()(const typename OP2::argument_type& x) const { return op1(op2(x),op3(x)); } }; /* convenience function for the compose_f_gx_hx adapter*/ template <class OP1, class OP2, class OP3> inline compose_f_gx_hx_t<OP1,OP2,OP3> compose_f_gx_hx (const OP1& o1, const OP2& o2, const OP3& o3) { return compose_f_gx_hx_t<OP1,OP2,OP3>(o1,o2,o3); } 复制代码 复制代码 #include <iostream> #include <list> #include <algorithm> #include <functional> #include "compose21.hpp" using namespace std; int main() { list<int> coll; list<int>::iterator pos; for(int i=20;i<=40;++i) coll.push_back(i); pos = find_if(coll.begin(),coll.end(), compose_f_gx_hx(logical_or<bool>(), bind2nd(equal_to<int>(),25), bind2nd(equal_to<int>(),35))); cout<<"num: "<<*pos<<endl; system("pause"); return 0; } 复制代码 2,三种迭代器适配器: 1) Insert iterator 插入位置可以是容器的最前或最后,或是在某一特定位置上. 复制代码 #include <iostream> #include <vector> #include <list> #include <deque> #include <set> #include <algorithm> using namespace std; int main() { list<int> coll1; // insert elements from 1 to 9 into the first collection for (int i=1; i<=9; ++i) { coll1.push_back(i); } // copy the elements of coll1 into coll2 by appending them vector<int> coll2; copy (coll1.begin(), coll1.end(), // source back_inserter(coll2)); // destination // copy the elements of coll1 into coll3 by inserting them at the front // - reverses the order of the elements deque<int> coll3; copy (coll1.begin(), coll1.end(), // source front_inserter(coll3)); // destination // copy elements of coll1 into coll4 // - only inserter that works for associative collections set<int> coll4; copy (coll1.begin(), coll1.end(), // source inserter(coll4,coll4.begin())); // destination return 0; } 复制代码 back_inserter的内部调用push_back(),在容器尾端插入元素,只有在提供有push_back()成员函数的容器中才能使用,这样的容器有:vector,deque,list. front_inserter的内部调用push_front(),在容器最前端插入元素,只有在提供有push_ front()成员函数的容器中才能使用,这样的容器有deque和list;一般性的inserter,作用是将元素插入”初始化时接受之第二参数”所指的位置的前方.它内部调用insert(). 2)Stream iterator.这是用来读写流的迭代器. 复制代码 #include <iostream> #include <vector> #include <string> #include <algorithm> #include <iterator> using namespace std; int main() { vector<string> coll; copy (istream_iterator<string>(cin), // start of source istream_iterator<string>(), // end of source back_inserter(coll)); // destination sort (coll.begin(), coll.end()); unique_copy (coll.begin(), coll.end(), // source ostream_iterator<string>(cout,"\n")); // destination } 复制代码 3)Reverse iterator 复制代码 #include <iostream> #include <vector> #include <algorithm> #include <iterator> using namespace std; int main() { vector<int> coll; // insert elements from 1 to 9 for (int i=1; i<=9; ++i) { coll.push_back(i); } // print all element in reverse order copy (coll.rbegin(), coll.rend(), // source ostream_iterator<int>(cout," ")); // destination cout << endl; } 复制代码 3,移除元素 复制代码 #include <iostream> #include <list> #include <algorithm> #include <iterator> using namespace std; int main() { list<int> coll; // insert elements from 6 to 1 and 1 to 6 for (int i=1; i<=6; ++i) { coll.push_front(i); coll.push_back(i); } // print all elements of the collection copy (coll.begin(), coll.end(),ostream_iterator<int>(cout," ")); cout << endl; list<int>::iterator end = remove (coll.begin(), coll.end(),3);//新的尾节点 // print resulting elements of the collection copy (coll.begin(), end,ostream_iterator<int>(cout," ")); cout << endl; // print number of resulting elements cout << "number of removed elements: "<< distance(end,coll.end()) << endl; // remove ``removed'' elements coll.erase (end, coll.end()); // print all elements of the modified collection copy (coll.begin(), coll.end(),ostream_iterator<int>(cout," ")); cout << endl; } 复制代码 本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/08/27/1278096.html,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

用户登录
用户注册