本文整理汇总了C++中GroupMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupMap::insert方法的具体用法?C++ GroupMap::insert怎么用?C++ GroupMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupMap
的用法示例。
在下文中一共展示了GroupMap::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGroups
void NetworkClient::GetGroups()
{
rMessage->Reset();
peer->RPC("ServerPeer::GetGroups", NULL , NULL, HIGH_PRIORITY, RELIABLE, 0, UNASSIGNED_SYSTEM_ADDRESS, true, 0, UNASSIGNED_NETWORK_ID,rMessage);
if( (rMessage->GetNumberOfUnreadBits()) > 0)
{
int count, groupId, len = 0;
char* groupName = "";
GroupMap g;
g.clear();
rMessage->Read(count);
for(int j = 0;j<count;j++)
{
rMessage->Read(groupId);
rMessage->Read(len);
groupName = new char[len+1];
groupName[len] = 0;
rMessage->Read(groupName, len);
g.insert(GroupMap::value_type(groupId, groupName));
}
if(!g.empty())
{
dataMan->setGroups(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);
}
}