本文整理汇总了C++中QVector::squeeze方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::squeeze方法的具体用法?C++ QVector::squeeze怎么用?C++ QVector::squeeze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::squeeze方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseTrace
void TraceLoader::parseTrace()
{
QList<ApiTraceFrame*> frames;
ApiTraceFrame *currentFrame = 0;
int frameCount = 0;
QVector<ApiTraceCall*> calls;
quint64 binaryDataSize = 0;
int lastPercentReport = 0;
trace::Call *call = m_parser.parse_call();
while (call) {
//std::cout << *call;
if (!currentFrame) {
currentFrame = new ApiTraceFrame();
currentFrame->number = frameCount;
++frameCount;
}
ApiTraceCall *apiCall =
apiCallFromTraceCall(call, m_helpHash, currentFrame, this);
calls.append(apiCall);
if (apiCall->hasBinaryData()) {
QByteArray data =
apiCall->arguments()[apiCall->binaryDataIndex()].toByteArray();
binaryDataSize += data.size();
}
if (ApiTrace::isCallAFrameMarker(apiCall,
m_frameMarker)) {
calls.squeeze();
currentFrame->setCalls(calls, binaryDataSize);
calls.clear();
frames.append(currentFrame);
currentFrame = 0;
binaryDataSize = 0;
if (frames.count() >= FRAMES_TO_CACHE) {
emit framesLoaded(frames);
frames.clear();
}
if (m_parser.percentRead() - lastPercentReport >= 5) {
emit parsed(m_parser.percentRead());
lastPercentReport = m_parser.percentRead();
}
}
delete call;
call = m_parser.parse_call();
}
//last frames won't have markers
// it's just a bunch of Delete calls for every object
// after the last SwapBuffers
if (currentFrame) {
calls.squeeze();
currentFrame->setCalls(calls, binaryDataSize);
frames.append(currentFrame);
currentFrame = 0;
}
if (frames.count()) {
emit framesLoaded(frames);
}
}
示例2: getProfile
MouseProfile MouseProfileDialog::getProfile() const
{
MouseProfile profile(m_profile);
profile.setTitle(m_ui->titleLineEditWidget->text());
profile.setDescription(m_ui->descriptionLineEditWidget->text());
profile.setVersion(m_ui->versionLineEditWidget->text());
profile.setAuthor(m_ui->authorLineEditWidget->text());
QHash<int, QVector<MouseProfile::Gesture> > definitions;
for (int i = 0; i < m_ui->gesturesViewWidget->getRowCount(); ++i)
{
const QModelIndex contextIndex(m_ui->gesturesViewWidget->getIndex(i, 0));
const int gestureAmount(m_ui->gesturesViewWidget->getRowCount(contextIndex));
if (gestureAmount > 0)
{
QVector<MouseProfile::Gesture> gestures;
gestures.reserve(gestureAmount);
for (int j = 0; j < gestureAmount; ++j)
{
const QModelIndex actionIndex(contextIndex.child(j, 0));
const QStringList steps(actionIndex.sibling(actionIndex.row(), 2).data(Qt::DisplayRole).toString().split(QLatin1String(", "), QString::SkipEmptyParts));
const int action(actionIndex.data(IdentifierRole).toInt());
if (!steps.isEmpty() && action >= 0)
{
MouseProfile::Gesture gesture;
gesture.action = action;
gesture.parameters = actionIndex.data(ParametersRole).toMap();
for (int k = 0; k < steps.count(); ++k)
{
gesture.steps.append(MouseProfile::Gesture::Step::fromString(steps.at(k)));
}
gestures.append(gesture);
}
}
gestures.squeeze();
if (gestures.count() > 0)
{
definitions[static_cast<GesturesManager::GesturesContext>(contextIndex.data(ContextRole).toInt())] = gestures;
}
}
}
profile.setDefinitions(definitions);
profile.setModified(m_ui->gesturesViewWidget->isModified());
return profile;
}
示例3: calculateStatistics
void Column::calculateStatistics() {
m_column_private->statistics = ColumnStatistics();
ColumnStatistics& statistics = m_column_private->statistics;
QVector<double>* rowValues = reinterpret_cast<QVector<double>*>(data());
int notNanCount = 0;
double val;
double columnSum = 0.0;
double columnProduct = 1.0;
double columnSumNeg = 0.0;
double columnSumSquare = 0.0;
statistics.minimum = INFINITY;
statistics.maximum = -INFINITY;
QMap<double, int> frequencyOfValues;
QVector<double> rowData;
rowData.reserve(rowValues->size());
for (int row = 0; row < rowValues->size(); ++row) {
val = rowValues->value(row);
if (std::isnan(val) || isMasked(row))
continue;
if (val < statistics.minimum){
statistics.minimum = val;
}
if (val > statistics.maximum){
statistics.maximum = val;
}
columnSum+= val;
columnSumNeg += (1.0 / val);
columnSumSquare += pow(val, 2.0);
columnProduct *= val;
if (frequencyOfValues.contains(val)){
frequencyOfValues.operator [](val)++;
}
else{
frequencyOfValues.insert(val, 1);
}
++notNanCount;
rowData.push_back(val);
}
if (notNanCount == 0) {
setStatisticsAvailable(true);
return;
}
if (rowData.size() < rowValues->size()){
rowData.squeeze();
}
statistics.arithmeticMean = columnSum / notNanCount;
statistics.geometricMean = pow(columnProduct, 1.0 / notNanCount);
statistics.harmonicMean = notNanCount / columnSumNeg;
statistics.contraharmonicMean = columnSumSquare / columnSum;
double columnSumVariance = 0;
double columnSumMeanDeviation = 0.0;
double columnSumMedianDeviation = 0.0;
double sumForCentralMoment_r3 = 0.0;
double sumForCentralMoment_r4 = 0.0;
gsl_sort(rowData.data(), 1, notNanCount);
statistics.median = (notNanCount % 2 ? rowData.at((notNanCount-1)/2) :
(rowData.at((notNanCount-1)/2) +
rowData.at(notNanCount/2))/2.0);
QVector<double> absoluteMedianList;
absoluteMedianList.reserve(notNanCount);
absoluteMedianList.resize(notNanCount);
int idx = 0;
for(int row = 0; row < rowValues->size(); ++row){
val = rowValues->value(row);
if ( std::isnan(val) || isMasked(row) )
continue;
columnSumVariance+= pow(val - statistics.arithmeticMean, 2.0);
sumForCentralMoment_r3 += pow(val - statistics.arithmeticMean, 3.0);
sumForCentralMoment_r4 += pow(val - statistics.arithmeticMean, 4.0);
columnSumMeanDeviation += fabs( val - statistics.arithmeticMean );
absoluteMedianList[idx] = fabs(val - statistics.median);
columnSumMedianDeviation += absoluteMedianList[idx];
idx++;
}
statistics.meanDeviationAroundMedian = columnSumMedianDeviation / notNanCount;
statistics.medianDeviation = (notNanCount % 2 ? absoluteMedianList.at((notNanCount-1)/2) :
(absoluteMedianList.at((notNanCount-1)/2) + absoluteMedianList.at(notNanCount/2))/2.0);
const double centralMoment_r3 = sumForCentralMoment_r3 / notNanCount;
const double centralMoment_r4 = sumForCentralMoment_r4 / notNanCount;
statistics.variance = columnSumVariance / notNanCount;
statistics.standardDeviation = sqrt(statistics.variance);
statistics.skewness = centralMoment_r3 / pow(statistics.standardDeviation, 3.0);
statistics.kurtosis = (centralMoment_r4 / pow(statistics.standardDeviation, 4.0)) - 3.0;
statistics.meanDeviation = columnSumMeanDeviation / notNanCount;
double entropy = 0.0;
//.........这里部分代码省略.........
示例4: parseTrace
void TraceLoader::parseTrace()
{
QList<ApiTraceFrame*> frames;
ApiTraceFrame *currentFrame = 0;
int frameCount = 0;
QStack<ApiTraceCall*> groups;
QVector<ApiTraceCall*> topLevelItems;
QVector<ApiTraceCall*> allCalls;
quint64 binaryDataSize = 0;
int lastPercentReport = 0;
trace::Call *call = m_parser.parse_call();
while (call) {
//std::cout << *call;
if (!currentFrame) {
currentFrame = new ApiTraceFrame();
currentFrame->number = frameCount;
++frameCount;
}
ApiTraceCall *apiCall =
apiCallFromTraceCall(call, m_helpHash, currentFrame, groups.isEmpty() ? 0 : groups.top(), this);
allCalls.append(apiCall);
if (groups.count() == 0) {
topLevelItems.append(apiCall);
}
if (call->flags & trace::CALL_FLAG_MARKER_PUSH) {
groups.push(apiCall);
} else if (call->flags & trace::CALL_FLAG_MARKER_POP) {
groups.top()->finishedAddingChildren();
groups.pop();
}
if (!groups.isEmpty()) {
groups.top()->addChild(apiCall);
}
if (apiCall->hasBinaryData()) {
QByteArray data =
apiCall->arguments()[apiCall->binaryDataIndex()].toByteArray();
binaryDataSize += data.size();
}
if (call->flags & trace::CALL_FLAG_END_FRAME) {
allCalls.squeeze();
topLevelItems.squeeze();
if (topLevelItems.count() == allCalls.count()) {
currentFrame->setCalls(allCalls, allCalls, binaryDataSize);
} else {
currentFrame->setCalls(topLevelItems, allCalls, binaryDataSize);
}
allCalls.clear();
groups.clear();
topLevelItems.clear();
frames.append(currentFrame);
currentFrame = 0;
binaryDataSize = 0;
if (frames.count() >= FRAMES_TO_CACHE) {
emit framesLoaded(frames);
frames.clear();
}
if (m_parser.percentRead() - lastPercentReport >= 5) {
emit parsed(m_parser.percentRead());
lastPercentReport = m_parser.percentRead();
}
}
delete call;
call = m_parser.parse_call();
}
//last frames won't have markers
// it's just a bunch of Delete calls for every object
// after the last SwapBuffers
if (currentFrame) {
allCalls.squeeze();
if (topLevelItems.count() == allCalls.count()) {
currentFrame->setCalls(allCalls, allCalls, binaryDataSize);
} else {
currentFrame->setCalls(topLevelItems, allCalls, binaryDataSize);
}
frames.append(currentFrame);
currentFrame = 0;
}
if (frames.count()) {
emit framesLoaded(frames);
}
}