Boost范围库(http://www.boost.org/doc/libs/1_35_0/libs/range/index.html)允许我们将一对迭代器抽象为一个范围.现在我想将两个范围合并为一个,即:
给定两个范围r1和r2,定义r遍历[r1.begin(),r1.end()[然后[r2.begin(),r2.end()[.有没有办法使用r1和r2将r定义为范围?
我和另一篇文章中描述的人有同样的问题.我的应用程序的日志文件很大(~1GB),而grep用于关联日志文件中的信息非常繁琐.现在我使用''less''工具,但它也比我想要的慢.
我在考虑加快搜索速度.有以下几种方法:首先,用XML生成日志并使用一些XML搜索工具.我不确定使用XML搜索会获得多少加速(我猜不多,因为非索引文件搜索仍需要很长时间).
其次,使用XML数据库.这会更好,但我在这里没有太多背景.
第三,使用(非XML)数据库.这有点单调乏味,因为必须编写表模式(上面的第二个选项也可以完成吗?).我还预见到一开始会改变很多模式以包含常见用例.理想情况下,我想要一个比完整的数据库更轻的东西来存储日志.
第四,使用lucene.它似乎符合目的,但有一种简单的方法来指定当前用例的索引吗?例如,我想说"每当你看到'迭代'这个词时索引".
你有什么意见?
我最近在我的C++代码库上运行了CCCC并收到了很多红色标记(在代码库中可以看到CCCC的示例输出(不是我的代码库)).我知道红色标记可能是由于基本的复杂性或偶然的复杂性,但CCCC并不区分这两者.我最关心的是我的代码库中名为" Henry and Kafura的信息流复杂性 " 的模块化度量值,它有很多红色标记.是否有任何工作描述任何工作流程建议或减少红色标记数量的处方?
我想为我的开源C++项目建立一个持续集成和测试框架.所需的功能是:
1. check out the source code
2. run all the unit and other tests
3. run performance tests (these measure the software quality - for example how long does it take the system to complete the test)
4. produce a report based on 3. and 4. daily
5. archive the reports for future reference
Run Code Online (Sandbox Code Playgroud)
要实现这一点,您会推荐哪个测试框架和持续集成过程?现在我倾向于使用Google Test Framework(我知道在其他问题中讨论的单元测试框架的一些比较)用于测试和Cruisecontrol用于持续集成.但我不知道Cruisecontrol是否允许轻松整合性能指标.
编辑:要回答Wilhelmtell,代码应该适用于Windows和Linux.
c++ continuous-integration automated-tests unit-testing cruisecontrol
在配备Intel Pentium双核处理器T2370(Acer Extensa)的笔记本电脑上,我运行了一个简单的多线程加速测试.我正在使用Linux.代码粘贴在下面.虽然我期待加速2-3次,但我惊讶地发现速度减慢了2倍.我尝试了同样的gcc优化等级-O0 ... -O3,但每次我得到相同的结果.我正在使用pthreads.我也尝试了同样只有两个线程(而不是代码中的3个线程),但性能类似.
可能是什么原因?更快的版本需要相当长的时间 - 大约20秒 - 所以它似乎不是启动开销的问题.
注意:这个代码有很多错误(事实上它没有多大意义,因为串行和并行版本的输出会有所不同).目的只是"获得"相同数量指令的加速比较.
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
class Thread{
private:
pthread_t thread;
static void *thread_func(void *d){((Thread *)d)->run();}
public:
Thread(){}
virtual ~Thread(){}
virtual void run(){}
int start(){return pthread_create(&thread, NULL, Thread::thread_func, (void*)this);}
int wait(){return pthread_join(thread, NULL);}
};
#include <iostream>
const int ARR_SIZE = 100000000;
const int N = 20;
int arr[ARR_SIZE];
int main(void)
{
class Thread_a:public Thread{
public:
Thread_a(int* a): arr_(a) {}
void run()
{
for(int n = …Run Code Online (Sandbox Code Playgroud) 我有一个用这个部分打开文件的类:
JFileChooser chooser=new JFileChooser();
chooser.setCurrentDirectory(new File("."));
int r = chooser.showOpenDialog(ChatFrame.this);
if (r != JFileChooser.APPROVE_OPTION) return;
try {
Login.is.sendFile(chooser.getSelectedFile(), Login.username,label_1.getText());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
然后我想将此文件保存在另一个文件中:
JFileChooser jfc = new JFileChooser();
int result = jfc.showSaveDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = jfc.getSelectedFile();
InputStream in;
try {
in = new FileInputStream(f);
OutputStream st=new FileOutputStream(jfc.getSelectedFile());
st.write(in.read());
st.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// …Run Code Online (Sandbox Code Playgroud) 我需要设计一个支持以下操作的数据结构:
我考虑使用list来添加和删除中间的元素.只有有限的间隔 - 所以可能使用地图是不对的.STL列表不能很好地支持这种访问(一个编写器,多个读取器).boost :: intrusive :: list似乎合适.在侵入列表的顶部,我将不得不获取锁来读/写间隔.
此外,我理解侵入列表可用于比STL列表更好的缓存局部性(以及对所包含对象的适当内存分配).
方法好吗?如果是,我也有兴趣了解您使用intrusive :: list的经验,特别是对于多线程应用程序.
请查看以下代码.这有什么问题?编译器给出了这个错误:
在复制构造函数
person::person(person&)': No matching function for call toperson :: copy(char*&,char*&)'候选者是:void person :: copy(char*&,const char*&)"
这是代码:
class person
{
public:
person();
person(person &);
private:
void copy(char*&,const char*&);
char* name, *fathername,* address;
};
void person::copy( char*& n, const char*& p)
{
int result;
result=strcmp(n,p);
if(result!=0)
{
n=new char[strlen(p)+1];
strcpy(n,p);
n[strlen(p)]='\0';
}
}
person::person(person &object)
{
copy(name,object.name);
copy(fathername,object.fathername);
copy(address, object.address);
}
Run Code Online (Sandbox Code Playgroud)
从这个问题的答案来看,到目前为止我所理解的是:编译器不允许将引用转换为常量引用,因为引用已经是常量.它们不能指向像指针一样的不同内存位置.我对吗?
我想在mediawiki中创建一个命令.例如,在乳胶中,我可以做到
\newcommand{\concept}{\textbf}
Run Code Online (Sandbox Code Playgroud)
是否可以为其创建别名'''foo'''?
我们正在编写一个使用gcc和Visual C++编译的应用程序.一些团队成员只使用Visual C++/Windows,而其他人只使用gcc/linux.由于编译器之间的差异,构建有时会中断.我已经"修复"了几个导致使用编译器选项来启用/禁用警告的构建中断的场景,但是目前我仍然坚持使用C++模板中使用的">>".
Visual Studio似乎单方面扩展了标准,将">>"包含在模板中作为有效表达式(这仅在建议的C++ 0x中有效).但是gcc不接受这个作为有效的模板.现在我无法在Visual Studio中找到一个选项来禁止">>"或在gcc中禁用">>".我该怎么办?
注意:这个问题是关于双角支架,而不是右移操作员.
c++ ×7
boost ×1
database ×1
gcc ×1
java ×1
latex ×1
logging ×1
mediawiki ×1
multicore ×1
oop ×1
performance ×1
swing ×1
unit-testing ×1
visual-c++ ×1
xml-database ×1