std::vector::emplace_backC++Containers librarystd::vectortemplatevoidemplace_back(Args&&...args);(since C++11)Appends a new element to the end of the ...
分类:
其他好文 时间:
2014-08-14 23:27:06
阅读次数:
212
本文以List容器为例子,介绍了STL的基本内容,从容器到迭代器,再到普通函数,而且例子丰富,通俗易懂。不失为STL的入门文章,新手不容错过! 0前言 1定义一个list 2使用list的成员函数push_back和push_front插入一个元素到list中 3 list的成员函数empt...
分类:
其他好文 时间:
2014-08-13 14:29:16
阅读次数:
249
#include
#include
#include
using namespace std;
void ComStr(char *str, string &s,int m)
{
if (m == 0)
{
cout<<s<<endl;
return ;
}
if (*str != '\0')
{
s.push_back(*str);
ComStr(str+1,s ...
分类:
其他好文 时间:
2014-08-12 17:14:34
阅读次数:
223
boost 循环缓冲区[cpp]view plaincopy#includeint_tmain(intargc,_TCHAR*argv[]){boost::circular_buffercb(3);//Insertsomeelementsintothebuffer.cb.push_back(1);c...
分类:
其他好文 时间:
2014-08-12 00:35:23
阅读次数:
243
#include //从小到大排列#include#includeusing namespace std;int main(){ int i,x; vectormy ; for(i=1;i>x; my.push_back(x); } sort(my.begin(),my.end()); f...
分类:
其他好文 时间:
2014-08-10 18:34:30
阅读次数:
188
C++为我们提供了安全的内存空间申请方式与释放方式,但是new与delete表达式却是把空间的分配回收与对象的构建销毁紧紧的关联在一起。实际上,作为与C语言兼容的语言,C++也为我们提供了更加底层的内存操作方式的。
谈C++就离不开STL,考虑一下vector
template class T>
void Vector::push_back(const T& t)
{
// are w...
分类:
编程语言 时间:
2014-08-09 00:14:07
阅读次数:
409
1. Thread with lambda function
基于前一章中的Lambda程序,我们进行了扩展,当前创建5个线程。
#include
#include
#include
#include
int main()
{
std::vector threadVec;
for(int i=0; i<5; ++i){
threadVec.push_back(std::thr...
分类:
编程语言 时间:
2014-08-06 23:09:02
阅读次数:
248
初始化:1. 默认构造:vector vint;2. 用包含10个元素的数组初始化:vector vint(ia, ia+10);算法:1. vint.push_back(i);2. vint.size();3. vint[i];代码: 1 #include 2 #include 3 using.....
分类:
其他好文 时间:
2014-08-06 21:44:52
阅读次数:
205
在2-SAT,最让我纠结的还是添加有向线段的函数了void add_clause(int i,int a,int j,int b){ int m=2*i+a; int n=2*j+b; G[m^1].push_back(n); G[n^1].push_back(m);}这里a,b因为只有真假两种情况...
分类:
其他好文 时间:
2014-08-06 14:24:11
阅读次数:
176
今天学的hash。说实话还没怎么搞懂,明天有时间把知识点总结写了,今天就小小的写个结题报告吧!题意: 在n (n.(2)创建vector对象,vector vec;(3)尾部插入数字:vec.push_back(a);(4)使用下标访问元素,cout::iterator it;for(it=vec....
分类:
其他好文 时间:
2014-08-05 22:26:30
阅读次数:
297