2014 年文章归档
共 291 篇文章
STL 之search,search_n,sort,binary_search
返回 作用:用来查找元素和元素排序 声明: #include <algorithm> template <class forwardItr1, class forwardItr2> forwardItr1 search(forwardItr1 first1, forwardItr1 last1,forwardItr2 first2,forwardItr2 last2); template <class forwardItr1, class forwardItr2,class binaryPredicate> forwardItr1 search(forwardItr1 first1, for…
2014-04-15 15:20
STL 之swap, iter_swap, swap_ranges
返回 作用:交换元素 声明: #include <algorithm> template<class Type> void swap(Type& objcet1, Type& objec2); template<class forwardItr1,class forwardItr2> void iter_swap(forwardItr1 first,forwardItr2 scecod); template<class forwardItr1, class forwardItr2> forwardItr2 swap_ranges(forwardItr1 first,forwardItr1 l…
2014-04-15 14:34
STL 之replace,replace_if,replace_copy,replace_copy_if
返回 作用:用一个新值替换指定区间内所有的指定元素。 声明: #include <algorithm> template <class forwardItr,class Type> void replace(forwardItr first, forwardItr last,const Type& oldValue const Type& newValue); template <class forwardItr, class unaryPredicate,class Type> void replace_if(forwardItr first, forwardItr last, unary…
2014-04-15 13:47
STL 之remove,remove_if,remove_copy,remove_copy_if
返回 作用:从序列中删除指定元素。 声明: #include <algorithm> template <class forwardItr,class Type> forwardItr remove(forwardItr first, forwardItr last, const Type& value); template <class forwardItr, class unaryPredicate> forwardItr remove_if(forwardItr first, forwardItr last, unaryPredicate op); template <class in…
2014-04-15 12:05
STL 之find,find_if,find_end,find_first_of
返回 作用:用来在一个指定的区间中查找元素。 1,find, find_if 原型: #include <algorithm> template <class inputItr,class size,class Type> inputItr find(inputItr first, inputItr last, const Type& searchValue); template <class inputItr, class unaryPredicate> inputItr find_if(inputItr first, inputItr last, UnaryPredicate op); …
2014-04-15 10:57
STL 之generate和generate_n
返回 作用:用来生成元素,并将其填充到一个序列中。 定义: #include <algorithm> template <class forwardItr, class function> void generate(forwardItr first, forwardItr last, function gen); template <class forwardItr, class size, class function> void generate_n(forwardItr first, size n, function gen); 示例代码: #include <iostream> #…
2014-04-15 09:37
玩转Web之Json(三)-----easy ui怎么把前台显示的dataGird中的所有数据序列化为json,返回到后台并解析
最近做一个项目时,需要在dataGird中插入<input>,即文本输入框,当点击提交时,需要把文本框里填的数据返以及其他列的一些信息以json数组的格式返回到后台,虽然我实现了该功能,但一直没找到简便的方法,今天终于在一位版主的点拨下找到了非常简单的方法。 var all = $("#dg").datagrid("getData"); var json =JSON.stringify(all.rows); 仅仅只需要这两行代码,其中dg是datagird的id,第一行是获取表格中加载完毕后的数据,第二行是将第一行获得的数据转化成json数组。 然后以ajax方式提交到后台即可,下面是我的提…
2014-04-14 19:50
STL 之fill和fill_n
返回 作用:向容器中填充元素。 定义: #include <algorithm> template <class forwardItr, class Type> void fill(forwardItr first, forwardItr last, const Type& value); template <class forwardItr, class size, class Type> void fill_n(forwardItr first, size n, const Type& value); 示例代码: #include <iostream> #include <list> #…
2014-04-14 19:15
STL 之插入迭代器
目录 int list[5] = {1, 3, 6, 9, 12}; vector<int> vList; copy(list,list+5,vList); 当使用上述方式进行赋值时,由于vList没有分配空间,而出错。 解决方法使用遍历数组,并调用push_back方法将元素保存到vList中。 另外一种比较好的方式是通过插入迭代器完成。 三种插入迭代器:back_inserter, front_inserter,inserter 示例代码: #include <iostream> #include <list> #include <algorithm> #include <string>…
2014-04-14 17:38
STL之函数对象
目录 为了使类属算法具有灵活性,STL常使用函数的重载机制为算法提供两种形式。算法的第一种形式使用的是常规的操作来实现。第二种形式中,算法可以根据用户指定的准测对元素经行处理。 函数对象包含了一个可以通过函数调用运算符()使用的函数。实际上,函数对象是重载了函数调用运算符operator()的类模板。 用户可以创建自己的函数对象。STL提供了算术函数对象,关系函数对象,逻辑函数对象。 算术函数对象: plus<type> 加 minus<type> 减 multiplies<type> 乘 divides<type> 除 modulus<type> 模 negate<type> 取反 示例代…
2014-04-14 17:20
STL 之修改算法
目录 通过重新排列,删除或改变元素的值来修改容器中的元素。 修改算法中改变元素顺序,而不改变其值的算法成为变异(Mutating),(M)。 copy copy_backward fill fill_n generate generate_n inplace_merge merge next_permutation(M) nth_element partial_sort partial_sort_copy partition(M) prev_permutation(M) random_shuffle(M) remove remove_copy remove_copy_if remove_if…
2014-04-14 16:24
STL 之数字算法
目录 用于在容器元素上执行数字计算。 accumulate inner_product adjacent_difference partial_sum
2014-04-14 16:24
STL 之修改算法
目录 通过重新排列,删除或改变元素的值来修改容器中的元素。 修改算法中改变元素顺序,而不改变其值的算法成为变异(Mutating),标蓝。 copy copy_backward fill fill_n generate generate_n inplace_merge iter_swap merge next_permutation nth_element partial_sort partial_sort_copy partition prev_permutation random_shuffle remove remove_copy remove_copy_if remove_if re…
2014-04-14 16:22
STL 之非修改算法
目录 只访问容器中的元素,而不修改这些元素。 adjacent_find equal equal_range find find_end find_first_of find_if for_each includes lower_bound mismatch count count_if max max_element min min_element binary_search search search_n upper_bound
2014-04-14 16:21
手机WEB页面(HTML5)实现一键拨号及短信发送功能
最近用到在web页面里面实现拨打电话的功能,在网上查找了很多解决方案,实验之后下面的两个比较好用: <a href="tel:137xxxxxxxx">一键拨打号码</a> <a href="sms:137xxxxxxx">一键发送短信</a> 微信内部自带的浏览器也是支持的
2014-04-14 14:30
eclipse SVN插件更换、修改svn帐号
eclipse里面装的svn插件,以前一个同事离职了,现在换我上岗,都是用的同一台公司的电脑,今天突然提交代码发现还是以前离职的同事的名字,怎么把它换成提交后是我的名字 删除掉C:\DocumentsandSettings\administrator\ApplicationData\Subversion\auth\svn.simple文件夹下的文件即可。 再更新文件或者提交会出现提示,输入用户名和密码 C:\Users\Administrator\AppData\Roaming\Subversion\auth\svn.simple 然后在eclipse选择项目--右键--SVN版本控制---…
2014-04-14 11:28
node.js第五课(模块与包)
概念:模块(Module)和包(Package)是Node.js最重要的支柱。开发一个具有一定规模的程序不可能只用一个文件,通常需要把各个功能拆分、分装、然后组合起来。模块正式为了实现这种方式而诞生,在浏览器JavaScript中,脚本模块的拆分和组合通常使用HTML的script标签来实现,Node.js提供了require函数来调用其他模块,而且模块都是基于文件,机制非常简单,模块和包的区别是透明的,因此经常不作区分。 一、模块 1.什么是模块 模块和文件是一一对应的。一个Node.js文件就是一个模块,这个文件可能是JavaScript代码、JSON或者编译过的C/C++扩展。 …
2014-04-14 09:02
node.js第四课(回调函数与事件)
一、回调函数 1.异步式读取文件 var fs=require('fs'); fs.readFile('file.txt','utf-8',function(err,data){ if(err){ console.log(err) }else{ console.log(data) } }); console.log('end.') 结果: end. Contents of the file. 2. 同步式读取文件 var fs=require('fs'); var data=fs.readFileSync('file.txt','utf-8'); console.log(data) c…
2014-04-13 23:52
node.js第三课(node.js异步式IO与事件编程)
Node.js最大的特性就是异步式I/O与事件紧密结合的编程模式。这种模式与传统的同步式IO线性的编程思路有很大的不同,因为控制流很大程度上要靠事件和回调函数来组织,一个逻辑要拆分为若干个单元格。 内容:阻塞和线程 1.同步式I/O或阻塞式I/O 线程在执行中如果遇到磁盘读写或网络通信,通常要耗费较长时间。这时操作系统会剥夺这个线程的CPU控制权,使其暂停执行,同时将资源让给其他的工作线程,这种线程调度方式成为阻塞,当I/O操作完毕时,操作系统将这个线程的阻塞状态解除,恢复其对CPU的控制权、令其继续执行。 2.异步式I/O或非阻塞式I/O 针对所有I/O操作不采用阻塞策略,当线程遇到…
2014-04-13 21:02