本文整理汇总了C++中QVector::cbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::cbegin方法的具体用法?C++ QVector::cbegin怎么用?C++ QVector::cbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::cbegin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logVectorLong
QString logVectorLong(const QVector<uint64> &ids) {
if (!ids.size()) return "[void list]";
QString idsStr = QString("[%1").arg(*ids.cbegin());
for (QVector<uint64>::const_iterator i = ids.cbegin() + 1, e = ids.cend(); i != e; ++i) {
idsStr += QString(", %2").arg(*i);
}
return idsStr + "]";
}
示例2: mtpUpdateDcOptions
void mtpUpdateDcOptions(const QVector<MTPDcOption> &options) {
QSet<int32> already, restart;
{
mtpDcOptions opts;
{
QReadLocker lock(mtpDcOptionsMutex());
opts = cDcOptions();
}
for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) {
const MTPDdcOption &optData(i->c_dcOption());
int32 id = optData.vid.v, idWithShift = id + (optData.vflags.v * _mtp_internal::dcShift);
if (already.constFind(idWithShift) == already.cend()) {
already.insert(idWithShift);
mtpDcOptions::const_iterator a = opts.constFind(idWithShift);
if (a != opts.cend()) {
if (a.value().ip != optData.vip_address.c_string().v || a.value().port != optData.vport.v) {
restart.insert(id);
}
}
opts.insert(idWithShift, mtpDcOption(id, optData.vflags.v, optData.vip_address.c_string().v, optData.vport.v));
}
}
{
QWriteLocker lock(mtpDcOptionsMutex());
cSetDcOptions(opts);
}
}
for (QSet<int32>::const_iterator i = restart.cbegin(), e = restart.cend(); i != e; ++i) {
MTP::restart(*i);
}
}
示例3: showDelayedServiceMsgs
void Window::showDelayedServiceMsgs() {
QVector<DelayedServiceMsg> toAdd = _delayedServiceMsgs;
_delayedServiceMsgs.clear();
for (QVector<DelayedServiceMsg>::const_iterator i = toAdd.cbegin(), e = toAdd.cend(); i != e; ++i) {
serviceNotification(i->first.first, i->second, i->first.second, true);
}
}
示例4: ewsXmlEnumReader
bool ewsXmlEnumReader(QXmlStreamReader &reader, QVariant &val, QVector<QString> items)
{
QString elmName = reader.name().toString();
QString text = reader.readElementText();
if (reader.error() != QXmlStreamReader::NoError) {
qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to read %1 element - invalid content.")
.arg(elmName);
reader.skipCurrentElement();
return false;
}
int i;
QVector<QString>::const_iterator it;
for (it = items.cbegin(); it != items.cend(); it++, i++) {
if (text == *it) {
val = i;
break;
}
}
if (it == items.cend()) {
qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to read %1 element - unknown value %2.")
.arg(elmName).arg(text);
return false;
}
return true;
}
示例5: bitset
QBitArray OsmAnd::RoutingRulesetContext::encode( const std::shared_ptr<const ObfRoutingSectionInfo>& section, const QVector<uint32_t>& roadTypes )
{
QBitArray bitset(ruleset->owner->_universalRules.size());
auto itTagValueAttribIdCache = owner->_tagValueAttribIdCache.find(section);
if(itTagValueAttribIdCache == owner->_tagValueAttribIdCache.cend())
itTagValueAttribIdCache = owner->_tagValueAttribIdCache.insert(section, QMap<uint32_t, uint32_t>());
for(auto itType = roadTypes.cbegin(); itType != roadTypes.cend(); ++itType)
{
auto type = *itType;
auto itId = itTagValueAttribIdCache->find(type);
if(itId == itTagValueAttribIdCache->end())
{
const auto& encodingRule = section->_d->_encodingRules[type];
assert(encodingRule);
auto id = ruleset->owner->registerTagValueAttribute(encodingRule->_tag, encodingRule->_value);
itId = itTagValueAttribIdCache->insert(type, id);
}
auto id = *itId;
if(bitset.size() <= id)
bitset.resize(id + 1);
bitset.setBit(id);
}
return bitset;
}
示例6:
QVector<TacheUnitaire*> ProjetManager::getTachesProgrammable()
{
QVector<TacheUnitaire*> res;
QVector<TacheUnitaire*> taches = this->getUnitaire();
for (QVector<TacheUnitaire*>::const_iterator it = taches.cbegin(); it != taches.cend(); ++it)
{
TacheUnitaire* t = *it;
if(t->estProgrammable())
res.push_back(t);
}
return res;
}
示例7: document
QVector<FileContainer> Documents::newerFileContainers(const QVector<FileContainer> &fileContainers) const
{
QVector<FileContainer> newerContainers;
auto documentIsNewer = [this] (const FileContainer &fileContainer) {
try {
return document(fileContainer).documentRevision() != fileContainer.documentRevision();
} catch (const DocumentDoesNotExistException &) {
return true;
}
};
std::copy_if(fileContainers.cbegin(),
fileContainers.cend(),
std::back_inserter(newerContainers),
documentIsNewer);
return newerContainers;
}
示例8: mtpUpdateDcOptions
void mtpUpdateDcOptions(const QVector<MTPDcOption> &options) {
QSet<int32> already, restart;
{
mtpDcOptions opts(cDcOptions());
for (QVector<MTPDcOption>::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) {
const MTPDdcOption &optData(i->c_dcOption());
if (already.constFind(optData.vid.v) == already.cend()) {
already.insert(optData.vid.v);
mtpDcOptions::const_iterator a = opts.constFind(optData.vid.v);
if (a != opts.cend()) {
if (a.value().ip != optData.vip_address.c_string().v || a.value().port != optData.vport.v) {
restart.insert(optData.vid.v);
}
}
opts.insert(optData.vid.v, mtpDcOption(optData.vid.v, optData.vhostname.c_string().v, optData.vip_address.c_string().v, optData.vport.v));
}
}
cSetDcOptions(opts);
}
for (QSet<int32>::const_iterator i = restart.cbegin(), e = restart.cend(); i != e; ++i) {
MTP::restart(*i);
}
}
示例9:
bool OsmAnd::MapRasterizer_P::containsHelper(const QVector< PointI >& points, const PointI& otherPoint)
{
uint32_t intersections = 0;
auto itPrevPoint = points.cbegin();
auto itPoint = itPrevPoint + 1;
for (const auto itEnd = points.cend(); itPoint != itEnd; itPrevPoint = itPoint, ++itPoint)
{
const auto& point0 = *itPrevPoint;
const auto& point1 = *itPoint;
if (Utilities::rayIntersect(point0, point1, otherPoint))
intersections++;
}
// special handling, also count first and last, might not be closed, but
// we want this!
const auto& point0 = points.first();
const auto& point1 = points.last();
if (Utilities::rayIntersect(point0, point1, otherPoint))
intersections++;
return intersections % 2 == 1;
}
示例10: selectBestModes
void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
{
// Identify the best resolutions available for the supposed XXXXp resolutions.
std::map<int, VideoMode> idealModes;
idealModes[120] = VideoMode(160, 120);
idealModes[240] = VideoMode(430, 240);
idealModes[360] = VideoMode(640, 360);
idealModes[480] = VideoMode(854, 480);
idealModes[720] = VideoMode(1280, 720);
idealModes[1080] = VideoMode(1920, 1080);
std::map<int, int> bestModeInds;
for (int i = 0; i < allVideoModes.size(); ++i)
{
VideoMode mode = allVideoModes[i];
// PS3-Cam protection, everything above 60fps makes no sense
if (mode.FPS > 60)
continue;
for (auto iter = idealModes.begin(); iter != idealModes.end(); ++iter)
{
int res = iter->first;
VideoMode idealMode = iter->second;
// don't take approximately correct resolutions unless they really
// are close
if (mode.norm(idealMode) > 300)
continue;
if (bestModeInds.find(res) == bestModeInds.end())
{
bestModeInds[res] = i;
continue;
}
int index = bestModeInds[res];
VideoMode best = allVideoModes[index];
if (mode.norm(idealMode) < best.norm(idealMode))
{
bestModeInds[res] = i;
continue;
}
if (mode.norm(idealMode) == best.norm(idealMode))
{
// prefer higher FPS and "better" pixel formats
if (mode.FPS > best.FPS)
{
bestModeInds[res] = i;
continue;
}
bool better = CameraDevice::betterPixelFormat(mode.pixel_format, best.pixel_format);
if (mode.FPS >= best.FPS && better)
bestModeInds[res] = i;
}
}
}
QVector<VideoMode> newVideoModes;
for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it)
{
VideoMode mode = allVideoModes[it->second];
if (newVideoModes.empty())
{
newVideoModes.push_back(mode);
}
else
{
int size = getModeSize(mode);
auto result = std::find_if(newVideoModes.cbegin(), newVideoModes.cend(),
[size](VideoMode mode) { return getModeSize(mode) == size; });
if (result == newVideoModes.end())
newVideoModes.push_back(mode);
}
}
allVideoModes = newVideoModes;
}
示例11: if
//.........这里部分代码省略.........
continue;
if (isHorizontal)
{
// Fill horizontal edge
const auto xMin = qFloor(qMin(edge->v0->x, edge->v1->x));
const auto xMax = qFloor(qMax(edge->v0->x, edge->v1->x));
/*for(auto x = xMin; x <= xMax; x++)
fillPoint(PointI(x, rowIdx));*/
continue;
}
//LogPrintf(LogSeverityLevel::Debug, "line %d. Adding edge %p y(%f %f)", rowIdx, edge, edge->v0->y, edge->v1->y);
aet.push_back(edge);
continue;
}
// If there are no active edges, we've finished filling
if (aet.isEmpty())
break;
assert(aet.size() % 2 == 0);
// Sort aet by X
qSort(aet.begin(), aet.end(), [](Edge* l, Edge* r) -> bool
{
return l->v0->x > r->v0->x;
});
// Find next row
for(; rowIdx < nextRow; rowIdx++)
{
const unsigned int pairsCount = aet.size() / 2;
auto itEdgeL = aet.cbegin();
auto itEdgeR = itEdgeL + 1;
for(auto pairIdx = 0u; pairIdx < pairsCount; pairIdx++, itEdgeL = ++itEdgeR, ++itEdgeR)
{
auto lEdge = *itEdgeL;
auto rEdge = *itEdgeR;
// Fill from l to r
auto lXf = lEdge->xOrigin + (rowIdx - lEdge->startRow + 0.5f) * lEdge->slope;
auto rXf = rEdge->xOrigin + (rowIdx - rEdge->startRow + 0.5f) * rEdge->slope;
auto xMinF = qMin(lXf, rXf);
auto xMaxF = qMax(lXf, rXf);
auto xMin = qFloor(xMinF);
auto xMax = qFloor(xMaxF);
LogPrintf(LogSeverityLevel::Debug, "line %d from %d(%f) to %d(%f)", rowIdx, xMin, xMinF, xMax, xMaxF);
/*for(auto x = xMin; x <= xMax; x++)
fillPoint(PointI(x, rowIdx));*/
}
}
// Deactivate those edges that have end at yNext
for(auto itEdge = aet.begin(); itEdge != aet.end();)
{
auto edge = *itEdge;
if (edge->endRow <= nextRow)
{
// When we're done processing the edge, fill it Y-by-X
auto startCol = qFloor(edge->v0->x);
auto endCol = qFloor(edge->v1->x);
auto revSlope = 1.0f / edge->slope;