本文整理汇总了C++中QMap::cend方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::cend方法的具体用法?C++ QMap::cend怎么用?C++ QMap::cend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::cend方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
std::shared_ptr<OsmAnd::RoutePlannerContext::RouteCalculationSegment> OsmAnd::RoutePlannerContext::RoutingSubsectionContext::loadRouteCalculationSegment(
uint32_t x31, uint32_t y31,
QMap<uint64_t, std::shared_ptr<const Model::Road> >& processed,
const std::shared_ptr<RouteCalculationSegment>& original_)
{
uint64_t id = (static_cast<uint64_t>(x31) << 31) | y31;
auto itSegment = _roadSegments.constFind(id);
if(itSegment == _roadSegments.cend())
return original_;
this->_access++;
auto original = original_;
auto segment = *itSegment;
while(segment)
{
auto road = segment->road;
auto roadPointId = RoutePlanner::encodeRoutePointId(road, segment->pointIndex);
auto itOtherRoad = processed.constFind(roadPointId);
if(itOtherRoad == processed.cend() || (*itOtherRoad)->points.size() < road->points.size())
{
processed.insert(roadPointId, road);
std::shared_ptr<RouteCalculationSegment> newSegment(new RouteCalculationSegment(road, segment->pointIndex));
newSegment->_next = original;
original = newSegment;
}
segment = segment->next;
}
return original;
}
示例2: moveFilesWhenRollback
void FileMover::moveFilesWhenRollback(const QMap<QString,Element> &tomove,const QMap<QString,Element> & todelete, QString prjNum)
{
QDir dir;
for(auto it=todelete.cend();it!=todelete.cbegin();){
it--;
qDebug()<<"delete from "+_originPath+it.value().getPath();
if(!it.value().isFolder())
QFile::remove(_originPath+it.value().getPath());
else dir.rmdir(_originPath+it.value().getPath());
}
/*for(auto elem:todelete.cend()){
qDebug()<<"delete from "+_originPath+elem.getPath();
if(!elem.isFolder())
QFile::remove(_originPath+elem.getPath());
else dir.rmdir(_originPath+elem.getPath());
}*/
for(auto elem:tomove){
QString from=_storagePath+"Project "+prjNum+ "/Version " + QString::number(elem.getVersionId()) +
+"/changed" + elem.getPath();
QString to=_originPath+elem.getPath();
qDebug()<<"copy from "<<from<<" to "<<to;
if(!elem.isFolder())
FileMover::copyFile(from,to);
else dir.mkdir(_originPath+elem.getPath());
}
}
示例3: gotWebPages
void ApiWrap::gotWebPages(const MTPmessages_Messages &msgs, mtpRequestId req) {
const QVector<MTPMessage> *v = 0;
switch (msgs.type()) {
case mtpc_messages_messages:
App::feedUsers(msgs.c_messages_messages().vusers);
App::feedChats(msgs.c_messages_messages().vchats);
v = &msgs.c_messages_messages().vmessages.c_vector().v;
break;
case mtpc_messages_messagesSlice:
App::feedUsers(msgs.c_messages_messagesSlice().vusers);
App::feedChats(msgs.c_messages_messagesSlice().vchats);
v = &msgs.c_messages_messagesSlice().vmessages.c_vector().v;
break;
}
QMap<int32, int32> msgsIds; // copied from feedMsgs
for (int32 i = 0, l = v->size(); i < l; ++i) {
const MTPMessage &msg(v->at(i));
switch (msg.type()) {
case mtpc_message:
msgsIds.insert(msg.c_message().vid.v, i);
break;
case mtpc_messageEmpty:
msgsIds.insert(msg.c_messageEmpty().vid.v, i);
break;
case mtpc_messageService:
msgsIds.insert(msg.c_messageService().vid.v, i);
break;
}
}
MainWidget *m = App::main();
for (QMap<int32, int32>::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) {
HistoryItem *item = App::histories().addToBack(v->at(*i), -1);
if (item) {
item->initDimensions();
if (m) m->itemResized(item);
}
}
const WebPageItems &items(App::webPageItems());
for (WebPagesPending::iterator i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
if (i.value() == req) {
if (i.key()->pendingTill > 0) {
i.key()->pendingTill = -1;
WebPageItems::const_iterator j = items.constFind(i.key());
if (j != items.cend()) {
for (HistoryItemsMap::const_iterator k = j.value().cbegin(), e = j.value().cend(); k != e; ++k) {
k.key()->initDimensions();
if (m) m->itemResized(k.key());
}
}
}
i = _webPagesPending.erase(i);
} else {
++i;
}
}
}
示例4: fill_table_from_qmap
void ExperimentConditionsDialog::fill_table_from_qmap(QMap<Element, double> const & target) {
for(auto it = target.cbegin(), end = target.cend(); it != end; ++it) {
auto row_count = ui->target_composition_table->rowCount();
ui->target_composition_table->insertRow(row_count);
set_component(row_count, QPair<Element, double>{{it.key().charge, it.key().mass}, it.value() * 100});
}
}
示例5: setSelections
void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections)
{
m_diffSelections.clear();
for (auto it = selections.cbegin(), end = selections.cend(); it != end; ++it) {
const QList<DiffSelection> diffSelections = it.value();
QList<DiffSelection> workingList;
for (const DiffSelection &diffSelection : diffSelections) {
if (diffSelection.start == -1 && diffSelection.end == 0)
continue;
if (diffSelection.start == diffSelection.end && diffSelection.start >= 0)
continue;
int j = 0;
while (j < workingList.count()) {
const DiffSelection existingSelection = workingList.takeAt(j);
const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection);
for (int k = 0; k < newSelection.count(); k++)
workingList.insert(j + k, newSelection.at(k));
j += newSelection.count();
}
workingList.append(diffSelection);
}
m_diffSelections.insert(it.key(), workingList);
}
}
示例6: while
ParameterContainer::ParameterContainer(const QMap<QString, QVariant> data)
{
if(!data.empty()){
QMap<QString, QVariant>::const_iterator it = data.cbegin();
while(it != data.cend()){
offsetSet(it.key(), it.value());
it++;
}
}
}
示例7: creer
QString AbstractLinkSql::creer(const QMap<int,QPair<bdd::createSql,bool>>& attCaract, const QMap<int, QString> &foreignKey) const
{
QString sql(wordSqlString(bdd::wordSql::Create));
sql.append(" ").append(m_table).append("(").append(attribut(Entity::Id)).append(" ").append(createSqlString(bdd::createSql::Primary));
for(int i = 1; i != m_nbrAtt; ++i)
{
sql.append(",").append(attribut(i)).append(" ").append(createSqlString(attCaract.value(i).first));
if(attCaract.value(i).second)
sql.append(" ").append(createSqlString(bdd::createSql::NotNull));
}
for(QMap<int, QString>::const_iterator i = foreignKey.cbegin(); i != foreignKey.cend(); ++i)
sql.append(",").append(createSqlString(bdd::createSql::Foreign)).append("(").append(attribut(i.key())).append(") ")
.append(createSqlString(bdd::createSql::Ref)).append(" ").append(i.value());
return sql;
}
示例8: evaluate
bool OsmAnd::MapStyleEvaluator_P::evaluate(
const std::shared_ptr<const Model::MapObject>& mapObject,
const QMap< uint64_t, std::shared_ptr<MapStyleRule> >& rules,
const uint32_t tagKey, const uint32_t valueKey,
MapStyleEvaluationResult* const outResultStorage,
bool evaluateChildren)
{
_inputValues[_builtinValueDefs->id_INPUT_TAG].asUInt = tagKey;
_inputValues[_builtinValueDefs->id_INPUT_VALUE].asUInt = valueKey;
const auto ruleId = MapStyle_P::encodeRuleId(tagKey, valueKey);
auto itRule = rules.constFind(ruleId);
if(itRule == rules.cend())
return false;
return evaluate(mapObject.get(), *itRule, outResultStorage, evaluateChildren);
}
示例9: prepareSearch
void ExternalToolsFilter::prepareSearch(const QString &entry)
{
m_results.clear();
Qt::CaseSensitivity useCaseSensitivity = caseSensitivity(entry);
const QMap<QString, ExternalTool *> externalToolsById = ExternalToolManager::toolsById();
auto end = externalToolsById.cend();
for (auto it = externalToolsById.cbegin(); it != end; ++it) {
ExternalTool *tool = *it;
if (tool->description().contains(entry, useCaseSensitivity) ||
tool->displayName().contains(entry, useCaseSensitivity)) {
LocatorFilterEntry filterEntry(this, tool->displayName(), QVariant::fromValue(tool));
filterEntry.extraInfo = tool->description();
m_results.append(filterEntry);
}
}
}
示例10: gotWebPages
void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) {
const QVector<MTPMessage> *v = 0;
switch (msgs.type()) {
case mtpc_messages_messages: {
const MTPDmessages_messages &d(msgs.c_messages_messages());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_messagesSlice: {
const MTPDmessages_messagesSlice &d(msgs.c_messages_messagesSlice());
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
case mtpc_messages_channelMessages: {
const MTPDmessages_channelMessages &d(msgs.c_messages_channelMessages());
if (channel) {
channel->ptsReceived(d.vpts.v);
} else {
LOG(("API Error: received messages.channelMessages when no channel was passed! (ApiWrap::gotWebPages)"));
}
if (d.has_collapsed()) { // should not be returned
LOG(("API Error: channels.getMessages and messages.getMessages should not return collapsed groups! (ApiWrap::gotWebPages)"));
}
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
v = &d.vmessages.c_vector().v;
} break;
}
if (!v) return;
QMap<uint64, int32> msgsIds; // copied from feedMsgs
for (int32 i = 0, l = v->size(); i < l; ++i) {
const MTPMessage &msg(v->at(i));
switch (msg.type()) {
case mtpc_message: msgsIds.insert((uint64(uint32(msg.c_message().vid.v)) << 32) | uint64(i), i); break;
case mtpc_messageEmpty: msgsIds.insert((uint64(uint32(msg.c_messageEmpty().vid.v)) << 32) | uint64(i), i); break;
case mtpc_messageService: msgsIds.insert((uint64(uint32(msg.c_messageService().vid.v)) << 32) | uint64(i), i); break;
}
}
for (QMap<uint64, int32>::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) {
HistoryItem *item = App::histories().addNewMessage(v->at(i.value()), NewMessageExisting);
if (item) {
item->initDimensions();
Notify::historyItemResized(item);
}
}
const WebPageItems &items(App::webPageItems());
for (WebPagesPending::iterator i = _webPagesPending.begin(); i != _webPagesPending.cend();) {
if (i.value() == req) {
if (i.key()->pendingTill > 0) {
i.key()->pendingTill = -1;
WebPageItems::const_iterator j = items.constFind(i.key());
if (j != items.cend()) {
for (HistoryItemsMap::const_iterator k = j.value().cbegin(), e = j.value().cend(); k != e; ++k) {
k.key()->initDimensions();
Notify::historyItemResized(k.key());
}
}
}
i = _webPagesPending.erase(i);
} else {
++i;
}
}
}
示例11: serialize
bool MaterialCompiler::serialize(Node *n, const QList<NodeLink *> &links, QString &typeName) {
QMap<Node *, CompiledNodeData>::iterator it = datas.find(n);
if(it != datas.end()) {
typeName = it.value().type;
return true;
} else {
it = datas.insert(n, {getUniqueId(), QString()});
}
QList<NodeLink *> endings;
for(NodeLink *l : links) {
if(l->getEnd()->getParent() == n) {
endings.append(l);
}
}
uint components = n->getIns().size();
QString generic = "generic";
for(NodeLink *l : endings) {
QString tpe;
if(!serialize(l->getStart()->getParent(), links, tpe)) {
return false;
}
QString type = maxType(tpe, l->getStart()->getData().toMap()["type"].toString());
components = components + computeComponents(type) - 1;
generic = maxType(generic, type);
}
components = qMax(uint(2), components);
if(generic == "generic" && !n->getIns().isEmpty()) {
generic = "float";
}
QString genericAppend = componentsToShader(components);
QMap<Property *, QString> props;
for(Property *e : n->getProperties()) {
if(!e->getValue().isNull()) {
props[e] = toShader(e->getValue());
}
}
for(NodeLink *l : endings) {
NodeOut *start = l->getStart();
NodeIn *end = l->getEnd();
QString var = castFunc(end, generic) + "(" + computeName(start) + ")";
props[end] = var;
}
if(props.size() != n->getProperties().size()) {
err = CompiledMaterial::NullProperty;
return false;
}
QString line = n->getData().toMap()["shader"].toString();
if(line.contains(QRegExp("\\bgenericAppend\\b")) && components > 4) {
err = CompiledMaterial::InvalidVector;
return false;
}
it.value().type = typeName = line.indexOf(QRegExp("\\bgeneric\\b")) < line.indexOf(QRegExp("\\bgenericAppend\\b")) ? genericAppend : generic; // <<<<< ???
line = line.replace(QRegExp("\\bgeneric\\b"), generic);
line = line.replace(QRegExp("\\bgenericAppend\\b"), genericAppend);
for(NodeOut *o : n->getOuts()) {
QString arg = o->getData().toMap()["arg"].toString();
line = line.replace(QRegExp("\\b" + arg + "\\b"), computeName(o));
}
for(auto it = props.cbegin(); it != props.cend(); it++) {
Property *prop = it.key();
QString arg = prop->getData().toMap()["arg"].toString();
line = line.replace(QRegExp("\\b" + arg + "\\b"), it.value());
}
shader += line + "\n";
return true;
}
示例12: query
void FuzzySearchImpl::query(const QString &req, QVector<Service::Item *> *res) const
{
QVector<QString> words;
for (QString &word : req.split(QRegExp("\\W+"), QString::SkipEmptyParts))
words.append(word.toLower());
QVector<QMap<Service::Item *, unsigned int>> resultsPerWord;
// Quit if there are no words in query
if (words.empty())
return;
// Split the query into words
for (QString &word : words)
{
unsigned int delta = word.size()/3;
// Get qGrams with counts of this word
QMap<QString, unsigned int> qGrams;
QString spaced(_q-1,' ');
spaced.append(word.toLower());
for (unsigned int i = 0 ; i < static_cast<unsigned int>(word.size()); ++i)
++qGrams[spaced.mid(i,_q)];
// Get the words referenced by each qGram an increment their
// reference counter
QMap<QString, unsigned int> wordMatches;
// Iterate over the set of qgrams in the word
for (QMap<QString, unsigned int>::const_iterator it = qGrams.cbegin(); it != qGrams.end(); ++it)
{
// Iterate over the set of words referenced by this qGram
for (QMap<QString, unsigned int>::const_iterator wit = _qGramIndex[it.key()].begin(); wit != _qGramIndex[it.key()].cend(); ++wit)
{
// CRUCIAL: The match can contain only the commom amount of qGrams
wordMatches[wit.key()] += (it.value() < wit.value()) ? it.value() : wit.value();
}
}
// Allocate a new set
resultsPerWord.push_back(QMap<Service::Item *, unsigned int>());
QMap<Service::Item *, unsigned int>& resultsRef = resultsPerWord.back();
// Unite the items referenced by the words accumulating their #matches
for (QMap<QString, unsigned int>::const_iterator wm = wordMatches.begin(); wm != wordMatches.cend(); ++wm)
{
// // Do some kind of (cheap) preselection by mathematical bound
// if (wm.value() < qGrams.size()-delta*_q)
// continue;
// Now check the (expensive) prefix edit distance
if (!checkPrefixEditDistance(word, wm.key(), delta))
continue;
for(Service::Item * item: _invertedIndex[wm.key()])
{
resultsRef[item] += wm.value();
}
}
}
// Intersect the set of items references by the (referenced) words
// This assusmes that there is at least one word (the query would not have
// been started elsewise)
QVector<QPair<Service::Item *, unsigned int>> finalResult;
if (resultsPerWord.size() > 1)
{
// Get the smallest list for intersection (performance)
unsigned int smallest=0;
for (unsigned int i = 1; i < static_cast<unsigned int>(resultsPerWord.size()); ++i)
if (resultsPerWord[i].size() < resultsPerWord[smallest].size())
smallest = i;
bool allResultsContainEntry;
for (QMap<Service::Item *, unsigned int>::const_iterator r = resultsPerWord[smallest].begin(); r != resultsPerWord[smallest].cend(); ++r)
{
// Check if all results contain this entry
allResultsContainEntry=true;
unsigned int accMatches = resultsPerWord[smallest][r.key()];
for (unsigned int i = 0; i < static_cast<unsigned int>(resultsPerWord.size()); ++i)
{
// Ignore itself
if (i==smallest)
continue;
// If it is in: check next relutlist
if (resultsPerWord[i].contains(r.key()))
{
// Accumulate matches
accMatches += resultsPerWord[i][r.key()];
continue;
}
allResultsContainEntry = false;
break;
}
// If this is not common, check the next entry
if (!allResultsContainEntry)
continue;
//.........这里部分代码省略.........