virtual void operator()() override { // u2::String szStr = "abcdefghijklmnopqrstuv"; // size_t uCurCount = 0; // while (uCurCount < szStr.size()) // { // uCurCount += m_pOutStream->write((const u2byte*)szStr.c_str() + uCurCount, szStr.size()); // } // // int a = 0; FileInStream* pFileIn = U2_NEW FileInStream("aaa", "D://messagebox.zip", std::ios_base::in | std::ios_base::binary); const size_t BUF_SIZE = 1000; u2char s[BUF_SIZE] = {0}; size_t uTotal = 0; while (!pFileIn->eof()) { size_t uReadCount = pFileIn->read(s, BUF_SIZE); size_t uWriteCount = 0; while (uWriteCount < uReadCount) { uWriteCount += m_pOutStream->write(s + uWriteCount, uReadCount - uWriteCount); } uTotal += uWriteCount; } pFileIn->close(); m_pOutStream->close(); }
void Data::ImportData(std::string DataFile) { std::ifstream FileInStream(DataFile.c_str()); std::string line; if (FileInStream.is_open()) { float sepal_length; float sepal_width; float petal_length; float petal_width; std::string flower_name; while (std::getline(FileInStream, line)) { std::istringstream InStringStream(line); InStringStream >> sepal_length >> sepal_width >> petal_length >> petal_width >> flower_name; DataStructure DS; DS.SepalLength = sepal_length; DS.PetalLength = petal_length; DS.SepalWidth = sepal_width; DS.PetalWidth = petal_width; DS.ClasskNNID = 0; if (flower_name == "Iris-setosa") { DS.ClassTrueID = 1; } else if (flower_name == "Iris-versicolor") { DS.ClassTrueID = 2; } else if (flower_name == "Iris-virginica") { DS.ClassTrueID = 3; } /* Import the Test and Training points */ if ((rand() % 3 + 1) == 3) { fNTest++; fTestPoints.push_back(DS); } else { fNTrain++; fTrainPoints.push_back(DS); } } }