유량 (double) 및 시간 (double)을 반환하는 장치에서 데이터를 가져옵니다. 나는 그들을 저장하고 유속을 얻기 위해 시간과 시간을 얻기 위해 유속을 사용하여 데이터에 접근 할 수 있어야합니다 ...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;
}
}