本文整理汇总了C++中multimap::count方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::count方法的具体用法?C++ multimap::count怎么用?C++ multimap::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::count方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// Maps highest frequency of codons to each amino acid
vector<float> CodonFrequency::createMaxMap(multimap<char, pair<int, float> > AAtoCodonMap){
// cout << "------maxFreq------" << endl;
vector<float> maxMap;
float maxFreq;
// Loops through all amino acids
// If char rep of AA exists
// Calculate highest frequency to maxMap
for (char AA = 'A'; AA <= 'Z'; AA++) {
int addressAA = AA - 65;
if (AA == 'B' || AA == 'J' || AA == 'O' || AA == 'U' || AA == 'X') {
maxMap.push_back(-1);
// continue;
}
else if (AAtoCodonMap.count(AA) > 1) {
maxFreq = findMax(AAtoCodonMap, AA);
maxMap.push_back(maxFreq);
// continue;
} else if (AAtoCodonMap.count(AA) == 1) {
maxMap.push_back(AAtoCodonMap.find(AA)->second.second);
}
// to print values: comment out the continues in if statements
// cout << addressAA << " " << AA << " " << maxMap[addressAA] << endl;
}
return maxMap;
}
示例2: insert_balanced
int insert_balanced(int id, Vec2 pos){
int quad_id = 0, depth = 0;
while(flat_tree.count(quad_id)>=max_items_per_quad){
++depth;
quad_id = get_quad_id(pos,depth);
// msgm(
// "quad_id",quad_id,
// "count()",flat_tree.count(quad_id),
// );
}
msgm("inserting", id, "at", quad_id, "has", flat_tree.count(quad_id));
insert(id,pos,depth);
return quad_id;
}
示例3: writeMetadataFile
void writeMetadataFile( const string coll, boost::filesystem::path outputFile,
map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
toolInfoLog() << "\tMetadata for " << coll << " to " << outputFile.string() << std::endl;
bool hasOptions = options.count(coll) > 0;
bool hasIndexes = indexes.count(coll) > 0;
BSONObjBuilder metadata;
if (hasOptions) {
metadata << "options" << options.find(coll)->second;
}
if (hasIndexes) {
BSONArrayBuilder indexesOutput (metadata.subarrayStart("indexes"));
// I'd kill for C++11 auto here...
const pair<multimap<string, BSONObj>::iterator, multimap<string, BSONObj>::iterator>
range = indexes.equal_range(coll);
for (multimap<string, BSONObj>::iterator it=range.first; it!=range.second; ++it) {
indexesOutput << it->second;
}
indexesOutput.done();
}
ofstream file (outputFile.string().c_str());
uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());
file << metadata.done().jsonString();
}
示例4: writeMetadataFile
void writeMetadataFile( const string coll, boost::filesystem::path outputFile,
map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
log() << "\tMetadata for " << coll << " to " << outputFile.string() << endl;
ofstream file (outputFile.string().c_str());
uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());
bool hasOptions = options.count(coll) > 0;
bool hasIndexes = indexes.count(coll) > 0;
if (hasOptions) {
file << "{options : " << options.find(coll)->second.jsonString();
if (hasIndexes) {
file << ", ";
}
} else {
file << "{";
}
if (hasIndexes) {
file << "indexes:[";
for (multimap<string, BSONObj>::iterator it=indexes.equal_range(coll).first; it!=indexes.equal_range(coll).second; ++it) {
if (it != indexes.equal_range(coll).first) {
file << ", ";
}
file << (*it).second.jsonString();
}
file << "]";
}
file << "}";
}
示例5: contarElementosMultimap
//devuelve cuantos elementos de 'mi_multimap' usan 'llave' como llave
int contarElementosMultimap(multimap<string,int> mi_multimap,string llave)
{//Creo una variable donde guardare los valores de multimap, con la funcion "count" de multimap cuento a ver cuantos valores tiene el multimap y retorno la variable para saber cuantos veces se hayaron los valores
int conta=1; //por warning los inicialize
if(conta != 0)
{
conta = mi_multimap.count(llave);
}
return conta;
}
示例6: balance_all
void balance_all(){
// int prev = -1; // unused
for(auto&a:has_children){
if(flat_tree.count(a)>=max_items_per_quad)
balance(a);
}
// for(auto1)
}
示例7: printmultimap
void printmultimap(multimap <string, string> &authors)
{
typedef multimap <string, string>::size_type sz_type;
sz_type co = authors.count("Barth, John");
//cout << count;
multimap <string, string>::iterator iter = authors.find("Barth, John");
for (sz_type cnt = 0; cnt != co; ++cnt,++iter)
{
cout << iter->first << ":--->" << iter->second << endl;
}
}
示例8: balance
void balance(int id){
auto count = flat_tree.count(id);;
if (count > max_items_per_quad) {
int target_depth = get_depth(id) + logn(count, 4);
for (auto&a : query_quad(id)) {
//flat_tree.insert({})
insert(id, positions[id], target_depth);
}
flat_tree.erase(id); // erase all by key, can also erase iterator
}
}
示例9: sumaElementosMultimap
//devuelve la suma de los elementos de 'mi_multimap' que usan 'llave' como llave
int sumaElementosMultimap(multimap<string, int> mi_multimap, string llave)
{
int cont = 0; // Creo una variable cont
while(mi_multimap.count(llave) != 0) //mientras el conteo de las llaves no sea cero
{
int c = mi_multimap.find(llave)-> second; //La variable c toma el valor del segundo elemento de la llave
cont = cont + c; //Suma los valores
mi_multimap.erase(mi_multimap.find(llave)); //se borra el ultimo elemento
}
return cont; //devuelve la suma
}
示例10: printMap
// Prints each codon that codes for the amino acid
void CodonFrequency::printMap(multimap<char, pair<int, float> > AAtoCodonMap) {
for (char AA = 'A'; AA <= 'Z'; AA++) {
pair< multimap<char, pair<int, float> >::iterator, multimap<char, pair<int, float> >::iterator> ret;
if (AAtoCodonMap.count(AA) <= 0) continue;
ret = AAtoCodonMap.equal_range(AA);
cout << AA << " =>";
for (multimap<char, pair<int, float> >::iterator it = ret.first; it!=ret.second; ++it) {
cout << ' ' << it->second.first;
}
cout << endl;
}
}
示例11: main
int main()
{
init();
rdio(namenum);
lli n;
cin >> n;
if (M.count(n) > 0) {
for (auto it = M.equal_range(n).first; it != M.equal_range(n).second; ++it) {
cout << it->second << endl;
}
} else cout << "NONE" << endl;
return 0;
}
示例12: preprocess
void preprocess() {
for (int i = 0; i < raw_heads.size(); i++) {
raw_head_to_body.insert(pair<int,int>(toInt((Lit) raw_heads[i]), i));
}
for (int i = 0; i < raw_heads.size(); i++) {
if (raw_posb[i].size() == 1 && raw_negb[i].size() == 0) {
if (raw_head_to_body.count(toInt((Lit) raw_posb[i][0])) == 1) {
int r = raw_head_to_body.find(toInt((Lit) raw_posb[i][0]))->second;
raw_bl[i] = raw_posb[i][0];
raw_posb[r].copyTo(raw_posb[i]);
raw_negb[r].copyTo(raw_negb[i]);
raw_heads[r] = bv_false;
}
}
}
for (int i = 0; i < raw_heads.size(); i++) {
if (raw_heads[i] == bv_false) continue;
getId(raw_heads[i]);
}
}
示例13: contarElementosMultimap
//devuelve cuantos elementos de 'mi_multimap' usan 'llave' como llave
int contarElementosMultimap(multimap<string,int> mi_multimap,string llave)
{
return mi_multimap.count(llave); //count cuenta los valores del multimap
}
示例14: initParamsFromDOM
void InputHandler::initParamsFromDOM(DOMNode *node, multimap<string, ParamWrapper*> registry)
{
assert(node);
char *tmp = XMLString::transcode(node->getNodeName());
crusde_debug("%s, line: %d, initParamsFromDOM for node: %s.", __FILE__, __LINE__, tmp);
XMLString::release(&tmp);
DOMNode *child = node->getFirstChild();
DOMNamedNodeMap *attributes = NULL;
DOMNode *attr = NULL;
multimap<string, ParamWrapper*>::iterator key_iter;
pair< multimap<string, ParamWrapper*>::iterator, multimap<string, ParamWrapper*>::iterator > key_range;
list<string> params_set;
int count_keys(-1);
unsigned int count_set(0);
int empty_param(0);
while (child)
{
if( child->getNodeType() == DOMNode::ELEMENT_NODE)
{
attributes = child->getAttributes();
attr = attributes->getNamedItem(ATTR_name.xmlStr());
char* name = XMLString::transcode(attr->getNodeValue());
if( XMLString::compareIString(child->getNodeName(), TAG_parameter.xmlStr()) == 0 )
{
//get number of keys that equal name
count_keys = static_cast<int>( registry.count(string(name)) );
//if there is anything in the registry ...
if( count_keys > 0 )
{
//equal_range gives two results: an iterator to the first and last element with key==name
key_range = registry.equal_range(string(name));
//all keys have values that are adresses of double variables in the repsective plugins
//each of those variables now gets a value assigned. the same value.
for ( key_iter=key_range.first; key_iter != key_range.second; ++key_iter)
{
//get the value from the DOM
StrXML value(attributes->getNamedItem(ATTR_value.xmlStr())->getNodeValue());
//write it into the variable that's strored at key_iter->second
if( (key_iter->second)->isString() )
{
(key_iter->second)->setValue( value.cppStr() );
}
else if( (key_iter->second)->isDouble() )
{
(key_iter->second)->setValue( static_cast<double>( atof(value.cStr()) ) );
}
++count_set;
}
//memorize the key that was set only once
params_set.push_back(key_range.first->first);
}
else //if not found there might be a spelling mistake either in input, or plugin, or both :)
{
StrXML paramName(attributes->getNamedItem(ATTR_name.xmlStr())->getNodeValue());
crusde_warning("Parameter %s (coming from the experiment definition) not registered! Misspelled in XML file or Plug-in definition?",paramName.cStr());
}
}
XMLString::release(&name);
}
child = child->getNextSibling();
}
//two cases are possible for leftover parameters:
// i) they are optional parameters - check registry for that
// ii) they are unitialized - oh well, we gotta stop there
if(count_set < registry.size())
{
multimap<string, ParamWrapper*>::iterator map_iter = registry.begin();
list<string>::iterator found_iter;
string out_string("Error: Parameters that remain uninitialized: \n");
while (map_iter != registry.end())
{
if(!map_iter->second->isOptional())
{
found_iter = params_set.begin();
//as long as we're not at the end and could not find the parameter in the list of set
//parameters, continue looking.
while( found_iter != params_set.end() && (*found_iter).compare(map_iter->first) != 0 )
{
++found_iter;
}
//if we're at the end, the parameter was not in out list ... tell the user.
if(found_iter==params_set.end() )
{
++empty_param;
out_string.append("\t");
out_string.append(map_iter->first);
out_string.append("\n");
//.........这里部分代码省略.........