我正在从一个返回流速(双倍)和时间(双倍)的设备获取数据。我想存储它们,并能够使用流速来获取时间和时间来获取流速来访问数据。。。
我使用两个stl:map容器来完成此操作。。。有没有办法只使用一个容器?
Here is the method to load the data: Flow data (sData) is a comma delimited string ("11.2, 22.3, 14.3, 12.4, 13.3") Data is gathered each 0.25 seconds - so we just increment the time ...
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;
}
}