本文整理汇总了C++中OutputBuffer::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputBuffer::clear方法的具体用法?C++ OutputBuffer::clear怎么用?C++ OutputBuffer::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputBuffer
的用法示例。
在下文中一共展示了OutputBuffer::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMsScans
//.........这里部分代码省略.........
try {
int percentDone = 0;
int numScans = pRawData->GetNumScans();
std::vector<double> mzs;
std::vector<double> intensities;
for(int i=pRawData->GetFirstScanNum(); i<=pRawData->GetLastScanNum(); i=pRawData->GetNextScanNum(i)) {
int msLevel = pRawData->GetMSLevel(i);
// MS level 1 indicates a survey (FTMS) scan
bool addThisScan = (msLevel==1) || (msLevel==2 && addMs2Peaks);
if(addThisScan) {
pRawData->GetRawData(&mzs, &intensities, i);
int scanNumber = i;
int numPeaks = mzs.size();
int numPeaksStored = 0;
// About 20% speedup - allocating what we need in advance
buf.ensureBufferHasSpace(numPeaks*2*sizeof(TJavaFloat));
// OUTPUT: m/z, intensity float pairs
std::vector<double>::iterator mzIt = mzs.begin();
std::vector<double>::iterator intIt = intensities.begin();
bool wasZero = false;
bool zeroStored = false;
TJavaFloat previousMass = 0.0;
while(mzIt!=mzs.end()) {
TJavaFloat newIntensity = (TJavaFloat)*intIt;
TJavaFloat newMass = (TJavaFloat)*mzIt;
bool isZero = newIntensity==(TJavaFloat)0.0;
// Skip long sequences of zeros. Retain only beginning and trailing zero for graph plotting
if(!wasZero) {
// Store current value
buf.addJavaFloat(newMass);
buf.addJavaFloat(newIntensity);
numPeaksStored++;
if(isZero) { // !wasZero, isZero
wasZero=true;
zeroStored=true;
}
} else { // wasZero
if(!isZero) {
wasZero=false;
if(!zeroStored) {
// Store the previous zero
buf.addJavaFloat(previousMass);
buf.addJavaFloat((TJavaFloat)0.0);
numPeaksStored++;
}
// Store current value
buf.addJavaFloat(newMass);
buf.addJavaFloat(newIntensity);
numPeaksStored++;
} else { // wasZero && isZero
// The current zero is not getting stored
zeroStored=false;
previousMass = newMass;
// Keep going, do not store anything
}
}
mzIt++;
intIt++;
}
// Store the last zero (if it did not get stored) to terminate our graph neatly
if(!zeroStored) {
buf.addJavaFloat(previousMass);
buf.addJavaFloat((TJavaFloat)0.0);
numPeaksStored++;
}
cse(sqlite3_bind_int(pStatement, 1, i));
cse(sqlite3_bind_int(pStatement, 2, numPeaksStored));
cse(sqlite3_bind_blob(pStatement, 3, buf.get(), buf.usedSize(), SQLITE_TRANSIENT));
rc = sqlite3_step(pStatement);
if(rc!=SQLITE_DONE) {
throw 1;
}
cse(sqlite3_reset(pStatement));
buf.clear();
}
int newPercent = 100 * i / numScans;
if(newPercent!=percentDone) {
percentDone=newPercent;
std::cout << "Adding peaks for scan " << i << " (" << percentDone << "%)\n";
}
}
} catch(...) {
std::cerr << "ERROR: problem extracting raw data from " << inputRawFileName << " into " << outputFileName << "\n";
return 1;
}
if(pStatement!=NULL) {
cse(sqlite3_finalize(pStatement));
}
return 0;
}