本文整理汇总了C++中GroupMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupMap::find方法的具体用法?C++ GroupMap::find怎么用?C++ GroupMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupMap
的用法示例。
在下文中一共展示了GroupMap::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CountSSMLeave
static void CountSSMLeave(const address &group, const address &source) {
address source_addr;
char tmp[64], tmp2[64];
GroupMap::iterator g = groupMap.find(group);
assert(g != groupMap.end());
source_addr.set_family(source.family());
source_addr.copy_address(source);
source_addr.set_port(0);
SourceMap::iterator s = g->second.find(source_addr);
assert(s != g->second.end());
SourceSet::iterator ss = s->second.find(source);
if (ss == s->second.end()) {
return;
}
if (verbose)
info("Removing beacon %s from (%s, %s)", source.to_string(tmp, sizeof(tmp)),
source_addr.to_string(tmp2, sizeof(tmp2)),
group.to_string(tmp2, sizeof(tmp2)));
s->second.erase(ss);
if (s->second.empty()) {
if (verbose)
info("No more beacons for (%s, %s), leaving group",
source_addr.to_string(tmp, sizeof(tmp)),
group.to_string(tmp2, sizeof(tmp2)));
SSMLeave(ssmMcastSock,group, source_addr);
g->second.erase(s);
}
if (g->second.empty()) {
if (verbose)
info("No more sources, unregistering group %s, ", group.to_string(tmp, sizeof(tmp)));
groupMap.erase(g);
}
}
示例2: QModelIndex
void ResultsTree::GroupSortProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
{
QAbstractProxyModel::setSourceModel(sourceModel);
groupItems.clear();
if (sourceModel)
{
// Create group items
typedef std::map< QVariant, int, QVariantCompare > GroupMap;
GroupMap groupMap;
int numRows = sourceModel->rowCount();
for (int i = 0; i < numRows; ++i)
{
QModelIndex ind = sourceModel->index(i, groupByCol, QModelIndex());
QVariant v = sourceModel->data(ind, Qt::DisplayRole);
GroupMap::iterator it = groupMap.find(v);
if (it == groupMap.end())
{
it = groupMap.insert(GroupMap::value_type(v, groupItems.size())).first;
groupItems.push_back(GroupItem(v));
}
groupItems[it->second].children.push_back(ind);
}
}
}
示例3: CountSSMJoin
static void CountSSMJoin(const address &group, const address &source) {
address source_addr;
char tmp[64], tmp2[64], tmp3[64];
source_addr.set_family(source.family());
source_addr.copy_address(source);
source_addr.set_port(0);
GroupMap::iterator g = groupMap.find(group);
if (g == groupMap.end()) {
if (verbose)
info("Registering SSM group %s", group.to_string(tmp, sizeof(tmp)));
g = groupMap.insert(std::make_pair(group, SourceMap())).first;
}
SourceMap::iterator s = g->second.find(source_addr);
if (s == g->second.end()) {
if (verbose)
info("Joining (%s, %s)", source_addr.to_string(tmp, sizeof(tmp)),
group.to_string(tmp2, sizeof(tmp2)));
if (SSMJoin(ssmMcastSock, group, source_addr) < 0) {
if (verbose)
info("Join failed, reason: %s", strerror(errno));
return;
} else {
s = g->second.insert(std::make_pair(source_addr, SourceSet())).first;
}
}
SourceSet::iterator ss = s->second.find(source);
if (ss == s->second.end()) {
if (verbose)
info("Adding beacon %s to (%s, %s)", source.to_string(tmp, sizeof(tmp)),
source_addr.to_string(tmp2, sizeof(tmp2)),
group.to_string(tmp3, sizeof(tmp3)));
s->second.insert(source);
}
}
示例4: loadIds
MojErr MojDbSearchCursor::loadIds(ObjectSet& idsOut)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojUInt32 groupNum = 0;
bool found = false;
MojSharedPtr<ObjectSet> group;
GroupMap groupMap;
for(;;) {
// get current id
MojObject id;
MojUInt32 idGroupNum = 0;
MojErr err = m_storageQuery->getId(id, idGroupNum, found);
MojErrCheck(err);
if (!found)
break;
// if it is in a new group, create a new set
if (!group.get() || idGroupNum != groupNum) {
// find/create new group
GroupMap::Iterator iter;
err = groupMap.find(idGroupNum, iter);
MojErrCheck(err);
if (iter != groupMap.end()) {
group = iter.value();
} else {
err = group.resetChecked(new ObjectSet);
MojErrCheck(err);
err = groupMap.put(idGroupNum, group);
MojErrCheck(err);
}
groupNum = idGroupNum;
}
// add id to current set
err = group->put(id);
MojErrCheck(err);
}
// no matches unless all groups are accounted for
MojUInt32 groupCount = m_storageQuery->groupCount();
for (MojUInt32 i = 0; i < groupCount; ++i) {
if (!groupMap.contains(i))
return MojErrNone;
}
// find intersection of all groups
GroupMap::ConstIterator begin = groupMap.begin();
for (GroupMap::ConstIterator i = begin; i != groupMap.end(); ++i) {
if (i == begin) {
// special handling for first group
idsOut = *(i.value());
} else {
MojErr err = idsOut.intersect(*(i.value()));
MojErrCheck(err);
}
}
return MojErrNone;
}
示例5: parseSubGroup
void parseSubGroup(filesystem::InputStream &stream, const std::string &string, int flags)
{
std::string groupName = string;
std::string superName;
splitString(string, groupName, superName, ':');
std::shared_ptr<ParserGroup> group(parserGroupFactory());
group->setFlags(flags);
if(!superName.empty())
{
GroupMap::iterator it = groups.find(superName);
if(it != groups.end())
*group.get() = *(*it).second;
}
stream >> *group;
groups[groupName] = group;
}
示例6: group
void ModelGrouper::group( GroupMap & grouped )
{
QList<QPersistentModelIndex> persistentGroupIndexes;
// If we are already grouped, we need to insert items into existing groups before creating new ones
if( mIsGrouped ) {
// Get persistent indexes for each group item, because regular ones may be invalidated by
// the move call in the loop
for( ModelIter it(model()); it.isValid(); ++it )
if( model()->translator(*it) == groupedItemTranslator() )
persistentGroupIndexes.append( *it );
foreach( QPersistentModelIndex idx, persistentGroupIndexes ) {
bool isEmptyGroup = model()->rowCount(idx) == 0;
QString groupVal = idx.sibling( idx.row(), mGroupColumn ).data( Qt::DisplayRole ).toString();
GroupMap::Iterator mapIt = grouped.find( groupVal );
if( mapIt != grouped.end() ) {
QModelIndexList toMove(fromPersist(mapIt.value()));
//LOG_5( QString("Moving indexes %1 to existing group item at index %2").arg(indexListToStr(toMove)).arg(indexToStr(idx)) );
model()->move( toMove, idx );
if( isEmptyGroup )
emit groupPopulated( idx );
if( mUpdateScheduled ) {
if( !mGroupItemsToUpdate.contains( idx ) )
mGroupItemsToUpdate.append(idx);
} else
// Tell the group item to update itself based on the added children
model()->setData( idx, QVariant(), GroupingUpdate );
grouped.erase( mapIt );
}
}
// Deal with any now-empty groups
for( QList<QPersistentModelIndex>::Iterator it = persistentGroupIndexes.begin(); it != persistentGroupIndexes.end(); )
if( model()->translator(*it) == groupedItemTranslator() && model()->rowCount(*it) == 0 ) {
emit groupEmptied(*it);
++it;
} else
it = persistentGroupIndexes.erase( it );
if( emptyGroupPolicy() == RemoveEmptyGroups )
model()->remove( fromPersist( persistentGroupIndexes ) );
}
示例7: removeSubGroup
void removeSubGroup(const std::string& name)
{
GroupMap::iterator it = groups.find(name);
if(it != groups.end())
groups.erase(it);
}