本文整理汇总了C++中DataTable::getColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTable::getColumn方法的具体用法?C++ DataTable::getColumn怎么用?C++ DataTable::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable::getColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromStream
void RewardMappingTools::readFromStream(istream& in, ProbabilisticRewardMapping& rewards)
throw (IOException)
{
try
{
DataTable* data = DataTable::read(in, "\t", true, -1);
vector<string> ids = data->getColumn(0);
data->deleteColumn(0); // Remove ids
data->deleteColumn(0); // Remove means
// Now parse the table:
size_t nbSites = data->getNumberOfColumns();
rewards.setNumberOfSites(nbSites);
size_t nbBranches = data->getNumberOfRows();
for (size_t i = 0; i < nbBranches; i++)
{
int id = TextTools::toInt(ids[i]);
size_t br = rewards.getNodeIndex(id);
for (size_t j = 0; j < nbSites; j++)
{
rewards(br, j) = TextTools::toDouble((*data)(i, j));
}
}
// Parse the header:
for (size_t i = 0; i < nbSites; i++)
{
string siteTxt = data->getColumnName(i);
int site = 0;
if (siteTxt.substr(0, 4) == "Site")
site = TextTools::to<int>(siteTxt.substr(4));
else
site = TextTools::to<int>(siteTxt);
rewards.setSitePosition(i, site);
}
delete data;
}
catch (Exception& e)
{
throw IOException(string("Bad input file. ") + e.what());
}
}