本文整理汇总了C++中VectorKKStr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorKKStr::size方法的具体用法?C++ VectorKKStr::size怎么用?C++ VectorKKStr::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorKKStr
的用法示例。
在下文中一共展示了VectorKKStr::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessStatusStr
void KKJob::ProcessStatusStr (const KKStr& statusStr)
{
log.Level (30) << "KKJob::ProcessStatusStr[" << statusStr << "]" << endl;
KKStr fieldName;
KKStr fieldValue;
VectorKKStr fields = statusStr.Split ('\t');
kkuint32 fieldNum = 0;
while (fieldNum < fields.size ())
{
fieldName = fields[fieldNum];
fieldNum++;
if (fieldNum < fields.size ())
{
fieldValue = fields[fieldNum];
fieldNum++;
}
else
{
fieldValue = "";
}
fieldName.Upper ();
fieldValue.TrimLeft ("\n\r\t ");
fieldValue.TrimRight ("\n\r\t ");
if (fieldName.CompareIgnoreCase ("JOBID") == 0)
jobId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("PARENTID") == 0)
parentId = atoi (fieldValue.Str ());
else if (fieldName.CompareIgnoreCase ("STATUS") == 0)
status = JobStatusFromStr (fieldValue);
else if (fieldName.CompareIgnoreCase ("NumProcessors") == 0)
numProcessors = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("NumPorcessesAllowed") == 0)
numPorcessesAllowed = fieldValue.ToInt ();
else if (fieldName.CompareIgnoreCase ("Prerequisites") == 0)
PrerequisitesFromStr (fieldValue);
else
{
ProcessStatusField (fieldName, fieldValue);
}
}
} /* ProcessStatusStr */
示例2: ParseParameterStr
void DataBaseServer::ParseParameterStr (const KKStr& parameterStr)
{
VectorKKStr parameterPairs = parameterStr.Split ("\t");
VectorKKStr::iterator idx;
for (idx = parameterPairs.begin (); idx != parameterPairs.end (); idx++)
{
VectorKKStr fields = (*idx).Split (":="); // Split by either ':' or '='
if (fields.size () < 2)
{
// Should be two fields; line must be malformed.
continue;
}
KKStr parameterName = fields[0].ToUpper ();
if ((parameterName == "EMBEDDED") || (parameterName == "EMB") || (parameterName == "E")) embedded = fields[1].ToBool ();
else if ((parameterName == "MYSQLDATADIR") || (parameterName == "MYSQL") || (parameterName == "MDD")) mySqlDataDir = fields[1];
else if ((parameterName == "DESCRIPTION") || (parameterName == "DESC") || (parameterName == "D")) description = fields[1];
else if ((parameterName == "HOSTNAME") || (parameterName == "HOST") || (parameterName == "H")) hostName = fields[1];
else if ((parameterName == "USERNAME") || (parameterName == "USER") || (parameterName == "U")) userName = fields[1];
else if ((parameterName == "PASSWORD") || (parameterName == "PW") || (parameterName == "P")) passWord = fields[1];
else if ((parameterName == "PORTNUM") || (parameterName == "PN")) portNum = fields[1].ToUint32 ();
else if ((parameterName == "DATABASENAME") || (parameterName == "DATABASE") || (parameterName == "DB")) dataBaseName = fields[1];
}
if (description.EqualIgnoreCase ("Embedded"))
embedded = true;
} /* ParseParameterStr */
示例3: ProcessData
void InstrumentDataPitchAndRoll::ProcessData (const KKStr& txt)
{
VectorKKStr fields = txt.Split (" \t\n\r");
if (fields.size () < 4)
return;
float pitch = -999.99f;
float roll = -999.99f;
KKStr fieldName = "";
KKStr fieldValue = "";
kkuint32 fieldNum = 0;
while (fieldNum < fields.size ())
{
fieldName = fields[fieldNum];
fieldName.Upper ();
fieldNum++;
if (fieldNum < fields.size ())
{
fieldValue = fields[fieldNum];
fieldNum++;
}
else
{
fieldValue = "";
}
if (fieldName == "R")
{
roll = fieldValue.ToFloat ();
}
else if (fieldName == "P")
{
pitch = fieldValue.ToFloat ();
}
}
manager->PitchAndRollData (curTextLineStartScanLine, pitch, roll);
} /* ProcessData */
示例4: PrerequisitesFromStr
void KKJob::PrerequisitesFromStr (const KKStr& s)
{
prerequisites.clear ();
if (s.CompareIgnoreCase ("None") != 0)
{
VectorKKStr fields = s.Split (',');
for (kkuint32 x = 0; x < fields.size (); ++x)
{
kkint32 p = fields[x].ToInt ();
prerequisites.push_back (p);
}
}
} /* PrerequisitesFromStr */
示例5: ProcessBatteryData
void InstrumentDataBatteryMeter::ProcessBatteryData (const KKStr& txt)
{
// We will be expecting 5 fields;
// <Current battery> <\t> <Bat 0 Voltage> <\t> .... <\t> <Bat-3 Voltage>
VectorKKStr fields = txt.Split (',');
if (fields.size () < (1 + numOfBatteries))
return;
// activeBattery is '1' based that is batteries '1' - '4'; so
// batteryLevels[0] = battery level for battery 1.
kkint32 activeBattery = fields[0].ToInt ();
if ((activeBattery < 1) || ((kkuint32)activeBattery > numOfBatteries))
return;
kkuint32 x;
for (x = 0; x < numOfBatteries; x++)
batteryLevels[x] = fields[x + 1].ToFloat ();
manager->BatteryData (curTextLineStartScanLine, activeBattery, batteryLevels);
} /* ProcessBatteryData */
示例6: ImportGPSDataGPGGA
void ImportGPSDataGPGGA (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastMinute = 0;
int linesRead = 0;
KKStr ln (256);
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
linesRead++;
ln = buff;
ln.TrimLeft ();
if (!ln.LocateStr ("GPGGA"))
continue;
VectorKKStr fields = ln.Parse (",");
if (fields.size () < 8)
continue;
if (!fields[2].EqualIgnoreCase ("$GPGGA"))
continue;
/*
0 1 2 3 4 5 6 7 8
06/01/2010, 23:59:59.818, $GPGGA, 235958, 2840.927, N, 08828.458, W, 2, 09,22.10,0,M,,,14,0000*12
06/02/2010, 00:00:10.818, $GPGGA, 000009, 2840.931, N, 08828.482, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:21.802, $GPGGA, 000020, 2840.929, N, 08828.505, W, 1, 09,0.89,0,M,,,,*21
06/02/2010, 00:00:31.818, $GPGGA, 000030, 2840.924, N, 08828.526, W, 1, 09,0.89,0,M,,,,*2C
06/02/2010, 00:00:42.818, $GPGGA, 000041, 2840.917, N, 08828.547, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:53.802, $GPGGA, 000052, 2840.906, N, 08828.568, W, 1, 09,1.00,0,M,,,,*22
06/02/2010, 00:01:03.802, $GPGGA, 000102, 2840.895, N, 08828.585, W, 1, 09,0.89,0,M,,,,*2E
06/02/2010, 00:01:13.818, $GPGGA, 000112, 2840.883, N, 08828.600, W, 1, 09,0.89,0,M,,,,*26
*/
KKStr dateStr = fields[0];
KKStr timeStr = fields[1];
KKStr latStr = fields[4];
KKStr logStr = fields[6];
auto x = latStr.LocateCharacter ('.');
if (!x)
continue;
KKStr latMinStr = latStr.SubStrPart (x - 2);
KKStr latDegStr = latStr.SubStrSeg (0, x - 2);
double latitude = latDegStr.ToDouble () + latMinStr.ToDouble () / 60.0;
if (fields[5].EqualIgnoreCase ("S"))
latitude = 0.0 - latitude;
x = logStr.LocateCharacter ('.');
if (!x)
continue;
KKStr logMinStr = logStr.SubStrPart (x - 2);
KKStr logDegStr = logStr.SubStrSeg (0, x - 2);
double longitude = logDegStr.ToDouble () + logMinStr.ToDouble () / 60.0;
if (fields[7].EqualIgnoreCase ("W"))
longitude = 0.0 - longitude;
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
//.........这里部分代码省略.........
示例7: GenerateFinalResultsReport
void RandomSplitJobManager::GenerateFinalResultsReport ()
{
KKStr reportFileName = osGetRootName (ManagerName ()) + "_Results.html;";
ofstream f (reportFileName.Str ());
f << "Run Time Parameters" << endl
<< "Run Time" << "\t" << osGetLocalDateTime () << endl
<< "configFileName" << "\t" << configFileName << endl
<< "DataFileName" << "\t" << dataFileName << endl
<< "Format" << "\t" << format->DriverName () << endl
<< "DataIndexFileName" << "\t" << dataIndexFileName << endl
<< "NumFolds" << "\t" << numFolds << endl
<< "NumSplits" << "\t" << numSplits << endl
<< "splitFraction" << "\t" << splitFraction << endl
<< endl;
KKJobList::const_iterator idx;
ConfusionMatrix2 avgResults (*(this->MLClasses ()));
KKB::uint x = 0;
for (idx = Jobs ()->begin (); idx != Jobs ()->end (); idx++)
{
RandomSplitJobPtr j = dynamic_cast<RandomSplitJobPtr> (*idx);
if (j->RandomSplitsResults () != NULL)
{
f << endl
<< "Random Split[" << j->SplitNum () << "]" << endl;
j->RandomSplitsResults ()->PrintConfusionMatrixTabDelimited (f);
f << endl << endl;
j->PrintClassCounts (f);
f << endl << endl;
avgResults.AddIn (*(j->RandomSplitsResults ()), log);
x++;
}
}
f << endl << "Mean Average of all random Splits." << endl;
avgResults.FactorCounts (1.0 / (double)x);
avgResults.PrintConfusionMatrixTabDelimited (f);
f << endl
<< endl
<< endl
<< endl
<< "Class Counts" << endl
<< endl;
kkuint32 numClasses = (kkuint32)mlClasses->size ();
VectorFloat classAccs;
VectorDouble knownCounts;
VectorDouble predCounts;
VectorDouble adjCounts;
VectorDouble adjCountsStdError;
VectorDouble predDelta;
VectorDouble adjDelta;
KKStr l1, l2, l3;
mlClasses->ExtractThreeTitleLines (l1, l2, l3);
VectorKKStr knownCountLines;
VectorKKStr predCountLines;
VectorKKStr adjCountLines;
VectorKKStr deltaPredCountLines;
VectorKKStr deltaAdjCountLines;
VectorKKStr accLines;
ConfusionMatrix2 totalCM (*MLClasses ());
int totalCmCount = 0;
// Known Counts
for (idx = Jobs ()->begin (); idx != Jobs ()->end (); idx++)
{
RandomSplitJobPtr j = dynamic_cast<RandomSplitJobPtr> (*idx);
if (j->RandomSplitsResults () != NULL)
{
KKStr splitNumStr = StrFormatInt (j->SplitNum (), "ZZZ0");
j->GetClassCounts (classAccs, knownCounts, predCounts, adjCounts, adjCountsStdError, predDelta, adjDelta);
totalCM.AddIn (*(j->RandomSplitsResults ()), log);
totalCmCount++;
KKStr accLine = "Acc By Class\t" + splitNumStr;
KKStr knownLine = "Known\t" + splitNumStr;
KKStr predLine = "Predicted\t" + splitNumStr;
KKStr adjLine = "Adjusted\t" + splitNumStr;
KKStr deltaPredLine = "Delta Pred\t" + splitNumStr;
KKStr deltaAdjLine = "Delta Adj\t" + splitNumStr;
double totalAcc = 0.0;
double totalDeltaPred = 0.0;
double totalDeltaAdj = 0.0;
for (x = 0; x < numClasses; x++)
//.........这里部分代码省略.........
示例8: BuildCmdLineParameters
void CmdLineExpander::BuildCmdLineParameters (const VectorKKStr& argv)
{
kkuint32 x = 0;
while (x < argv.size ())
{
KKStr s = argv[x];
x++;
KKStr sUpper = s.ToUpper();
if ((sUpper == "-L") || (sUpper == "-LOGFILE"))
{
if (x < argv.size ())
{
if (argv[x][(kkint16)0] != '-')
{
logFileName = argv[x];
if (!logFileName.Empty ())
log.AttachFile (logFileName);
x++;
}
}
if (logFileName.Empty ())
{
log.Level (-1) << std::endl << std::endl;
log.Level (-1) << applicationName << " - Invalid Log File Parameter (-L)." << endl;
log.Level (-1) << " Name of log file required." << endl;
log.Level (-1) << endl;
parmsGood = false;
}
}
else if (sUpper == "-CMDFILE")
{
KKStr cmdFileName = "";
if (x < argv.size ())
{
if (argv[x][(kkint16)0] != '-')
{
cmdFileName = argv[x];
x++;
}
}
if (cmdFileName.Empty ())
{
log.Level (-1) << endl << endl << endl
<< applicationName << " " << "BuildCmdLineParameters *** ERROR ***" << endl << endl
<< "-CMDFILE option did not define a file name." << endl
<< endl;
parmsGood = false;
}
else
{
if (FileInStack (cmdFileName, cmdFileStack))
{
log.Level (-1) << endl << endl << endl
<< applicationName << " BuildCmdLineParameters *** ERROR ***" << endl
<< endl
<< "-CMDFILE [" << cmdFileName << "] is being called recursively." << endl
<< endl;
parmsGood = false;
}
else
{
bool validFile = true;
cmdFileStack.push_back (cmdFileName);
VectorKKStr cmdFileParameters;
ExtractParametersFromFile (cmdFileName, cmdFileParameters, validFile);
BuildCmdLineParameters (cmdFileParameters);
cmdFileStack.pop_back ();
if (!validFile)
parmsGood = false;
}
}
}
else
{
expandedParameters.push_back (s);
}
}
} /* BuildCmdLineParameters */
示例9: classSummaries
//.........这里部分代码省略.........
{
LLoydsEntryListPtr allClassesLLoydsEntries = DeriveAllLLoydsBins (images);
// Create a report for all classes
KKStr randomReportFileName;
if (reportFileName.Empty ())
randomReportFileName = "RandomDistanceReport_All.txt";
else
randomReportFileName = osRemoveExtension (reportFileName) + "_Random_All.txt";
ofstream randomReport (randomReportFileName.Str ());
randomReport << "Source Directory [" << sourceRootDirPath << "]" << endl;
randomReport << "Class [" << "All" << "]" << endl;
{
// Find the mean and stddev of Nearest Neighbor regardless of class.
NeighborList allClassesNeighbors (images, log);
allClassesNeighbors.FindNearestNeighbors (NeighborType::AnyPlankton, fromPlankton);
double allClassesMinDistAnyClass = 0.0f;
double allClassesMaxDistAnyClass = 0.0f;
allClassesNeighbors.CalcStatistics (allClassesMeanNNDAnyClass,
allClassesMeanStdDevAnyClass,
allClassesMinDistAnyClass,
allClassesMaxDistAnyClass
);
}
RandomNND randomizeLocations (lastScanLine,
images,
numOfIterations,
numOfBuckets,
bucketSize,
randomReport,
log
);
randomizeLocations.GenerateReport ();
// All classes Z-Score
double allClassesRandomMeanNND = randomizeLocations.NND_Mean ();
double allClassesRandomStdDevNND = randomizeLocations.NND_StdDev ();
double allClassesRealDataU2Stat = randomizeLocations.RealDataU2Stat ();
double z_Score = Z_Score (allClassesMeanNNDAnyClass, allClassesRandomMeanNND, allClassesRandomStdDevNND, images.QueueSize ());
KKStr zScoreSummaryLine = KKStr ("All-Classes") + "\t" +
StrFormatDouble (allClassesMeanNNDAnyClass, "###,##0.00") + "\t" +
StrFormatDouble (allClassesMeanStdDevAnyClass, "###,##0.00") + "\t" +
StrFormatDouble (allClassesRandomMeanNND, "###,##0.00") + "\t" +
StrFormatDouble (allClassesRandomStdDevNND, "###,##0.00") + "\t" +
StrFormatDouble (z_Score, "###,##0.00");
zScoreSummaryLines.push_back (zScoreSummaryLine);
randomReport << endl << endl << endl
<< "Z-Score" << endl
<< "=======" << endl
<< endl
<< "SampleMeanNND " << "\t" << allClassesMeanNNDAnyClass << endl
<< "SampleStdDevNND " << "\t" << allClassesMeanStdDevAnyClass << endl
<< "RandomMeanNND " << "\t" << allClassesRandomMeanNND << endl
<< "RandomStdDevNND " << "\t" << allClassesRandomStdDevNND << endl
<< "------- Z-Score " << "\t" << z_Score << endl
<< endl;
classSummaries.PushOnBack (new ClassSummary (MLClass::CreateNewMLClass (KKStr ("AllClasses")),
allClassesLLoydsEntries,
(float)allClassesRealDataU2Stat,
(float)z_Score
)
);
}
{
// Z-Score Summary Report
KKB::kkuint32 x;
*report << std::endl << std::endl
<< "Z-Score Summary By Class" << std::endl
<< std::endl
<< "ClassName" << "\t" << "SampleMean" << "\t" << "SampleStdDev" << "\t" << "RandomMean" << "\t" << "RandomStdDev" << "\t" << "Z-Score" << std::endl
<< "=========" << "\t" << "==========" << "\t" << "============" << "\t" << "==========" << "\t" << "============" << "\t" << "=======" << std::endl;
for (x = 0; x < zScoreSummaryLines.size (); x++)
*report << zScoreSummaryLines[x] << std::endl;
}
*report << endl << endl << endl;
classSummaries.SummaryReport (*report);
*report << endl << endl << endl;
classSummaries.SpatialOverlapReport (*report);
classSummaries.SaveLLoydsBinsData (lloydsBinsFileName, sourceRootDirPath, lastScanLine, baseLLoydsBinSize);
} /* RandomReport */