我从一个返回流量(双倍)和时间(双倍)的设备获取数据。我想存储他们,并能够访问数据使用两种流速来获取流量的时间和速度...stl:地图和镜像数据访问
我正在使用两个stl:map容器来做到这一点......有没有办法只使用一个容器?
这里是加载数据的方法: 流数据(SDATA)的逗号分隔的字符串(“11.2,22.3,14.3,12.4,13.3”) 数据收集每个0.25秒 - 所以我们只递增时间...
void LiquidTest::Load(string sData)
{
string sFlow;
istringstream iss(sData);
cout << "Inside LiquidTest::Load()." << endl;
double dTime = 0.0;
double dFlow = 0.0;
while (getline(iss, sFlow, ','))
{
// add the flow/time to the map(s)
cout << "Adding flow/time to map. sFlow=" << sFlow << ", dTime=" << dTime << "." << endl;
// Convert my string to a double
std::stringstream s(sFlow);
s >> dFlow;
// add the flow data and time data to the maps. We will then
// be able to access the flow by the time key and the time
// by the flow key. Do I need two maps ???
m_mapFlowDataKeyTime.insert(pair<double, double>(dFlow, dTime));
m_mapTimeKeyFlowData.insert(pair<double, double>(dTime, dFlow));
// Increment the time
dTime += 0.25;
}
}