本文整理汇总了C++中GroupMap类的典型用法代码示例。如果您正苦于以下问题:C++ GroupMap类的具体用法?C++ GroupMap怎么用?C++ GroupMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例3: 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);
}
}
}
示例4: 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);
}
}
}
示例5: input
//**********************************************************************************************************************
// This static function is intended to read all the necessary information from
// a pair of shared and design files needed for SVM classification. This information
// is used to build a LabeledObservationVector. Each element of the LabeledObservationVector
// looks like this:
// LabeledObservationVector[0] = pair("label 0", &vector[10.0, 21.0, 13.0])
// where the vector in the second position of the pair records OTU abundances.
void ClassifySvmSharedCommand::readSharedAndDesignFiles(const std::string& sharedFilePath, const std::string& designFilePath, LabeledObservationVector& labeledObservationVector, FeatureVector& featureVector) {
InputData input(sharedFilePath, "sharedfile");
vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
GroupMap designMap;
designMap.readDesignMap(designFilePath);
while ( lookup[0] != NULL ) {
readSharedRAbundVectors(lookup, designMap, labeledObservationVector, featureVector);
lookup = input.getSharedRAbundVectors();
}
}
示例6: process_message_group_ordering
//-----------------------------------------------------------------------------------------
void process_message_group_ordering(const GroupMap& gm)
{
for (GroupMap::const_iterator gitr(gm.begin()); gitr != gm.end(); ++gitr)
{
FieldTraitOrder go;
for (Presence::const_iterator flitr(gitr->second._fields.get_presence().begin());
flitr != gitr->second._fields.get_presence().end(); ++flitr)
go.insert(FieldTraitOrder::value_type(&*flitr));
unsigned gcnt(0);
for (FieldTraitOrder::iterator fto(go.begin()); fto != go.end(); ++fto)
(*fto)->_pos = ++gcnt;
if (!gitr->second._groups.empty())
process_message_group_ordering(gitr->second._groups);
}
}
示例7: LOG_TRACE
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;
}
示例8: 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;
}
示例9: foreach
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 ) );
}
示例10: copy
void copy(ParserGroupData &rhs)
{
values = rhs.values;
lines = rhs.lines;
groups.clear();
for(GroupMap::iterator it = rhs.groups.begin(); it != rhs.groups.end(); ++it)
{
boost::shared_ptr<ParserGroup> g(parserGroupFactory());
*g.get() = *(*it).second.get();
groups[(*it).first] = g;
}
}
示例11: writeStream
void writeStream(std::ostream &stream, int tabCount)
{
for(ValueMap::iterator vi = values.begin(); vi != values.end(); ++vi)
{
writeTabs(stream, tabCount);
stream << (*vi).first << " = " << (*vi).second.first << std::endl;
}
for(GroupMap::iterator gi = groups.begin(); gi != groups.end(); ++gi)
{
if((gi != groups.begin()) || (!values.empty()))
stream << std::endl;
writeTabs(stream, tabCount);
stream << (*gi).first << std::endl;
writeTabs(stream, tabCount);
stream << "{" << std::endl;
(*gi).second->writeStream(stream, tabCount + 1),
writeTabs(stream, tabCount);
stream << "}" << std::endl;
}
if(!lines.empty() && ((!groups.empty() || !values.empty())))
stream << std::endl;
for(LineList::iterator li = lines.begin(); li != lines.end(); ++li)
{
writeTabs(stream, tabCount);
std::string &f = (*li);
stream << (*li) << std::endl;
}
}
示例12: readSharedRAbundVectors
void ClassifySvmSharedCommand::readSharedRAbundVectors(vector<SharedRAbundVector*>& lookup, GroupMap& designMap, LabeledObservationVector& labeledObservationVector, FeatureVector& featureVector) {
for ( int j = 0; j < lookup.size(); j++ ) {
//i++;
vector<individual> data = lookup[j]->getData();
Observation* observation = new Observation(data.size(), 0.0);
string sharedGroupName = lookup[j]->getGroup();
string treatmentName = designMap.getGroup(sharedGroupName);
//std::cout << "shared group name: " << sharedGroupName << " treatment name: " << treatmentName << std::endl;
//labeledObservationVector.push_back(std::make_pair(treatmentName, observation));
labeledObservationVector.push_back(LabeledObservation(j, treatmentName, observation));
//std::cout << " j=" << j << " label : " << lookup[j]->getLabel() << " group: " << lookup[j]->getGroup();
for (int k = 0; k < data.size(); k++) {
//std::cout << " abundance " << data[k].abundance;
observation->at(k) = double(data[k].abundance);
if ( j == 0) {
featureVector.push_back(Feature(k, m->currentSharedBinLabels[k]));
}
}
//std::cout << std::endl;
// let this happen later?
//delete lookup[j];
}
}
示例13: getLLVMContext
// The following is common part for 'cilk vector functions' and
// 'omp declare simd' functions metadata generation.
//
void CodeGenModule::EmitVectorVariantsMetadata(const CGFunctionInfo &FnInfo,
const FunctionDecl *FD,
llvm::Function *Fn,
GroupMap &Groups) {
// Do not emit any vector variant if there is an unsupported feature.
bool HasImplicitThis = false;
if (!CheckElementalArguments(*this, FD, Fn, HasImplicitThis))
return;
llvm::LLVMContext &Context = getLLVMContext();
ASTContext &C = getContext();
// Common metadata nodes.
llvm::NamedMDNode *CilkElementalMetadata =
getModule().getOrInsertNamedMetadata("cilk.functions");
llvm::Metadata *ElementalMDArgs[] = {
llvm::MDString::get(Context, "elemental")
};
llvm::MDNode *ElementalNode = llvm::MDNode::get(Context, ElementalMDArgs);
llvm::Metadata *MaskMDArgs[] = {
llvm::MDString::get(Context, "mask"),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
llvm::IntegerType::getInt1Ty(Context), 1))
};
llvm::MDNode *MaskNode = llvm::MDNode::get(Context, MaskMDArgs);
MaskMDArgs[1] = llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
llvm::IntegerType::getInt1Ty(Context), 0));
llvm::MDNode *NoMaskNode = llvm::MDNode::get(Context, MaskMDArgs);
SmallVector<llvm::Metadata*, 8> ParameterNameArgs;
ParameterNameArgs.push_back(llvm::MDString::get(Context, "arg_name"));
llvm::MDNode *ParameterNameNode = 0;
// // Vector variant metadata.
// llvm::Value *VariantMDArgs[] = {
// llvm::MDString::get(Context, "variant"),
// llvm::UndefValue::get(llvm::Type::getVoidTy(Context))
// };
// llvm::MDNode *VariantNode = llvm::MDNode::get(Context, VariantMDArgs);
for (GroupMap::iterator GI = Groups.begin(), GE = Groups.end();
GI != GE;
++GI) {
CilkElementalGroup &G = GI->second;
// Parameter information.
QualType FirstNonStepParmType;
SmallVector<llvm::Metadata *, 8> AligArgs;
SmallVector<llvm::Metadata *, 8> StepArgs;
AligArgs.push_back(llvm::MDString::get(Context, "arg_alig"));
StepArgs.push_back(llvm::MDString::get(Context, "arg_step"));
// Handle implicit 'this' parameter if necessary.
if (HasImplicitThis) {
ParameterNameArgs.push_back(llvm::MDString::get(Context, "this"));
bool IsNonStepParm = handleParameter(*this, G, "this",
StepArgs, AligArgs);
if (IsNonStepParm)
FirstNonStepParmType = cast<CXXMethodDecl>(FD)->getThisType(C);
}
// Handle explicit paramenters.
for (unsigned I = 0; I != FD->getNumParams(); ++I) {
const ParmVarDecl *Parm = FD->getParamDecl(I);
StringRef ParmName = Parm->getName();
if (!ParameterNameNode)
ParameterNameArgs.push_back(llvm::MDString::get(Context, ParmName));
bool IsNonStepParm = handleParameter(*this, G, ParmName,
StepArgs, AligArgs);
if (IsNonStepParm && FirstNonStepParmType.isNull())
FirstNonStepParmType = Parm->getType();
}
llvm::MDNode *StepNode = llvm::MDNode::get(Context, StepArgs);
llvm::MDNode *AligNode = llvm::MDNode::get(Context, AligArgs);
if (!ParameterNameNode)
ParameterNameNode = llvm::MDNode::get(Context, ParameterNameArgs);
// If there is no vectorlengthfor() in this group, determine the
// characteristic type. This can depend on the linear/uniform attributes,
// so it can differ between groups.
//
// The rules for computing the characteristic type are:
//
// a) For a non-void function, the characteristic data type is the
// return type.
//
// b) If the function has any non-uniform, non-linear parameters, the
// the characteristic data type is the type of the first such parameter.
//
// c) If the characteristic data type determined by a) or b) above is
// struct, union, or class type which is pass-by-value (except fo
// the type that maps to the built-in complex data type)
// the characteristic data type is int.
//
// d) If none of the above three cases is applicable,
// the characteristic data type is int.
//.........这里部分代码省略.........
示例14: if
int ClassifySeqsCommand::execute(){
try {
if (abort) { if (calledHelp) { return 0; } return 2; }
string outputMethodTag = method;
if(method == "wang"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, util.getRandomNumber(), flip, writeShortcuts, current->getVersion()); }
else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, util.getRandomNumber(), current->getVersion()); }
else if(method == "zap"){
outputMethodTag = search + "_" + outputMethodTag;
if (search == "kmer") { classify = new KmerTree(templateFileName, taxonomyFileName, kmerSize, cutoff); }
else { classify = new AlignTree(templateFileName, taxonomyFileName, cutoff); }
}
else {
m->mothurOut(search + " is not a valid method option. I will run the command using wang.");
m->mothurOutEndLine();
classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, util.getRandomNumber(), flip, writeShortcuts, current->getVersion());
}
if (m->getControl_pressed()) { delete classify; return 0; }
m->mothurOut("Classifying sequences from " + fastafile + " ...\n" );
string baseTName = util.getSimpleName(taxonomyFileName);
//set rippedTaxName to
string RippedTaxName = "";
bool foundDot = false;
for (int i = baseTName.length()-1; i >= 0; i--) {
if (foundDot && (baseTName[i] != '.')) { RippedTaxName = baseTName[i] + RippedTaxName; }
else if (foundDot && (baseTName[i] == '.')) { break; }
else if (!foundDot && (baseTName[i] == '.')) { foundDot = true; }
}
if (outputDir == "") { outputDir += util.hasPath(fastafile); }
map<string, string> variables;
variables["[filename]"] = outputDir + util.getRootName(util.getSimpleName(fastafile));
variables["[tag]"] = RippedTaxName;
variables["[tag2]"] = outputMethodTag;
string newTaxonomyFile = getOutputFileName("taxonomy", variables);
string newaccnosFile = getOutputFileName("accnos", variables);
string tempTaxonomyFile = outputDir + util.getRootName(util.getSimpleName(fastafile)) + "taxonomy.temp";
string taxSummary = getOutputFileName("taxsummary", variables);
if ((method == "knn") && (search == "distance")) {
string DistName = getOutputFileName("matchdist", variables);
classify->setDistName(DistName); outputNames.push_back(DistName); outputTypes["matchdist"].push_back(DistName);
}
outputNames.push_back(newTaxonomyFile); outputTypes["taxonomy"].push_back(newTaxonomyFile);
outputNames.push_back(taxSummary); outputTypes["taxsummary"].push_back(taxSummary);
long start = time(NULL);
int numFastaSeqs = createProcesses(newTaxonomyFile, tempTaxonomyFile, newaccnosFile, fastafile);
if (!util.isBlank(newaccnosFile)) { m->mothurOut("\n[WARNING]: mothur reversed some your sequences for a better classification. If you would like to take a closer look, please check " + newaccnosFile + " for the list of the sequences.\n");
outputNames.push_back(newaccnosFile); outputTypes["accnos"].push_back(newaccnosFile);
}else { util.mothurRemove(newaccnosFile); }
m->mothurOut("\nIt took " + toString(time(NULL) - start) + " secs to classify " + toString(numFastaSeqs) + " sequences.\n\n");
start = time(NULL);
//read namefile
map<string, vector<string> > nameMap;
map<string, vector<string> >::iterator itNames;
if(namefile != "") {
m->mothurOut("Reading " + namefile + "..."); cout.flush();
nameMap.clear(); //remove old names
util.readNames(namefile, nameMap);
m->mothurOut(" Done.\n");
}
//output taxonomy with the unclassified bins added
ifstream inTax;
util.openInputFile(newTaxonomyFile, inTax);
ofstream outTax;
string unclass = newTaxonomyFile + ".unclass.temp";
util.openOutputFile(unclass, outTax);
//get maxLevel from phylotree so you know how many 'unclassified's to add
int maxLevel = classify->getMaxLevel();
//read taxfile - this reading and rewriting is done to preserve the confidence scores.
string name, taxon;
GroupMap* groupMap = NULL;
CountTable* ct = NULL;
PhyloSummary* taxaSum;
if (hasCount) {
ct = new CountTable();
ct->readTable(countfile, true, false);
taxaSum = new PhyloSummary(ct, relabund, printlevel);
}else {
if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); }
taxaSum = new PhyloSummary(groupMap, relabund, printlevel);
}
while (!inTax.eof()) {
if (m->getControl_pressed()) { outputTypes.clear(); if (ct != NULL) { delete ct; } if (groupMap != NULL) { delete groupMap; } delete taxaSum; for (int i = 0; i < outputNames.size(); i++) { util.mothurRemove(outputNames[i]); } delete classify; return 0; }
//.........这里部分代码省略.........
示例15: removeSubGroup
void removeSubGroup(const std::string& name)
{
GroupMap::iterator it = groups.find(name);
if(it != groups.end())
groups.erase(it);
}