【发布时间】:2018-08-02 09:08:51
【问题描述】:
我使用 C++ 的“xtensor”库。在它的帮助下,我尝试创建一个包含用户数据的数据表类。 有时我需要通过用户 ID 列表对一些用户组数据进行子集化。对于这个任务,我使用布尔标志系统来标记我想要复制到新表的用户。
class UserDataTable {
private:
xt::xarray<bool> which;
//... more code
}
UserDataTable::UserDataTable(int size){
//... more code
std::vector<std::size_t> shape(size, 1);
std::vector<bool> boolinit(size);
which = xt::adapt(binit, shape);
//... more code
}
在子集函数中有这样的代码:
for(int usercounter=0; usercounter<USER_LIST_COUNT; usercounter++){
std::string id = userlist(usercounter);
if(indexMap.count(id)>0){
int index = indexMap[id];
which(index) = true;
}
}
但是这行代码: 其中(索引)=真; 将“true”值分配给所有“which”数组元素。 我做错了什么?
【问题讨论】: