小编nar*_*ren的帖子

linux中c"fopen"可以打开的最大文件数

fopen在Linux中,c 可以同时打开的最大文件数是多少?

c fopen

7
推荐指数
2
解决办法
6894
查看次数

如何在c ++中有效地比较集合?

我想使用equal算法比较两组,但它给了我一个错误.怎么知道两套是否相等?

if(equal (a.begin(), a.end(), v.begin(), v.end())
Run Code Online (Sandbox Code Playgroud)

c++ c++11

6
推荐指数
2
解决办法
229
查看次数

如何使用std :: threads将多维映射的引用传递给函数

我按照以下方式编写代码

#include <iostream>
#include <thread>
#include <map>
using namespace std;
void hi (map<string,map<string,int> > &m ) {
   m["abc"]["xyz"] =1;
   cout<<"in hi";
}
int main() {
   map<string, map<string, int> > m;
   thread t = thread (hi, m);
   t.join();
   cout << m.size();
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

我通过2D地图m参考hi函数,我更新但它没有反映在main函数中.当我打印m.size()时它只打印零.我可以使用线程将2D地图引用传递给函数吗?

c++ multithreading reference c++11

3
推荐指数
1
解决办法
425
查看次数

如何有效地使用std :: threads来减少运行时间

我的代码如下:

int main()
{
  thread t[10];
  for (int i = 0;i < 10; i++)
    t[i] = thread(print,i);//thread creation
  for (int i = 0;i < 10; i++)
    t[i].join();//waiting maiin to threads to cpmleate execution
  cout << "in main";
}

void print(int i) {
  cout<<"i:"<<endl;
}
Run Code Online (Sandbox Code Playgroud)

这是最有效的方式,还是有更有效的方法来减少运行时间?

c++ parallel-processing multithreading c++11

1
推荐指数
1
解决办法
734
查看次数

c ++ map erase功能与迭代器无法正常工作

我通过以下方式使用擦除从地图中删除元素,但它无法正常工作.为什么?它并没有全部删除.

float nw_cut=80.0;
for(it=nw_tot1.begin();it!=nw_tot1.end();it++)
{
    float f=(float) ((float) it->second/lines)*100.0;
    if ( f < nw_cut )
    {
        nw_tot1.erase(it);
    }
}
Run Code Online (Sandbox Code Playgroud)

c++ c++11

0
推荐指数
1
解决办法
1068
查看次数

标签 统计

c++ ×4

c++11 ×4

multithreading ×2

c ×1

fopen ×1

parallel-processing ×1

reference ×1