本文整理汇总了C++中multimap::size方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::size方法的具体用法?C++ multimap::size怎么用?C++ multimap::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
/* Look for mime handler in pool */
static RecollFilter *getMimeHandlerFromCache(const string& key)
{
PTMutexLocker locker(o_handlers_mutex);
string xdigest;
MD5HexPrint(key, xdigest);
LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n",
xdigest.c_str(), o_handlers.size()));
multimap<string, RecollFilter *>::iterator it = o_handlers.find(key);
if (it != o_handlers.end()) {
RecollFilter *h = it->second;
hlruit_tp it1 = find(o_hlru.begin(), o_hlru.end(), it);
if (it1 != o_hlru.end()) {
o_hlru.erase(it1);
} else {
LOGERR(("getMimeHandlerFromCache: lru position not found\n"));
}
o_handlers.erase(it);
LOGDEB(("getMimeHandlerFromCache: %s found size %u\n",
xdigest.c_str(), o_handlers.size()));
return h;
}
LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str()));
return 0;
}
示例2: Erasing_Prescribed_Candidates
void CDetCandit::Erasing_Prescribed_Candidates(multimap<double, size_t>& FeedbackCase_mm)
{
if((int)FeedbackCase_mm.size() > FEEDBACK_CASES_NUM){
for(int num = FeedbackCase_mm.size() - FEEDBACK_CASES_NUM; num > 0; num--){
FeedbackCase_mm.erase(FeedbackCase_mm.begin());
}
}
}
示例3:
void operator& (multimap<double,double> x, ostream& stream) {
x.size() & stream;
for (multimap<double,double>::const_iterator pos = x.begin (); pos != x.end() ; ++pos) {
pos->first & stream;
pos->second & stream;
}
}
示例4: checkBadDest
int Slave::checkBadDest(multimap<int64_t, Address>& sndspd, vector<Address>& bad)
{
bad.clear();
if (sndspd.empty())
return 0;
int m = sndspd.size() / 2;
multimap<int64_t, Address>::iterator p = sndspd.begin();
for (int i = 0; i < m; ++ i)
++ p;
int64_t median = p->first;
int locpos = 0;
for (multimap<int64_t, Address>::iterator i = sndspd.begin(); i != sndspd.end(); ++ i)
{
if (i->first > (median / 2))
return bad.size();
bad.push_back(i->second);
locpos ++;
}
return bad.size();
}
示例5: search_image
void Vocabulary::search_image(int imgNum, vector<int> images, multimap<int, int> &imageScore, vector<int> &rankedScore)
{
for(int i=0; i<imgNum; i++)
{
imageScore.insert(pair<int,int>(i+1,0));
}
cout<<imageScore.size()<<endl;
int score=0;
for(auto ite=imageScore.begin(); ite!=imageScore.end(); ite++)
{
for(int i=0; i<images.size(); i++)
{
if((*ite).first==images[i])
{
(*ite).second++;
}
}
///normalize
float normalized_score=(float)(*ite).second/(float)images.size();
// (*ite).second=normalized_score;
cout.precision(5);
cout<<(*ite).first<<" "<<(*ite).second<<" "<<normalized_score<<endl;
rankedScore.push_back((*ite).second);
}
}
示例6: RayCast
bool CMesh::RayCast(VECTOR4D & RayOrigin, VECTOR4D & RayDir, multimap<float, unsigned long>& Vertices, float radius) {
for (size_t i = 0; i < m_Vertices.size(); i++) {
if (RaySphereIntersect(RayOrigin, RayDir, m_Vertices[i].Position, radius)) {
float dist = Magnity(m_Vertices[i].Position - RayOrigin);
Vertices.insert(make_pair(dist, (unsigned long)i));
}
}
return Vertices.size() > 0;
}
示例7: returnMimeHandler
/* Return mime handler to pool */
void returnMimeHandler(RecollFilter *handler)
{
typedef multimap<string, RecollFilter*>::value_type value_type;
if (handler == 0) {
LOGERR(("returnMimeHandler: bad parameter\n"));
return;
}
handler->clear();
PTMutexLocker locker(o_handlers_mutex);
LOGDEB(("returnMimeHandler: returning filter for %s cache size %d\n",
handler->get_mime_type().c_str(), o_handlers.size()));
// Limit pool size. The pool can grow quite big because there are
// many filter types, each of which can be used in several copies
// at the same time either because it occurs several times in a
// stack (ie mail attachment to mail), or because several threads
// are processing the same mime type at the same time.
multimap<string, RecollFilter *>::iterator it;
if (o_handlers.size() >= max_handlers_cache_size) {
static int once = 1;
if (once) {
once = 0;
for (it = o_handlers.begin(); it != o_handlers.end(); it++) {
LOGDEB1(("Cache full. key: %s\n", it->first.c_str()));
}
LOGDEB1(("Cache LRU size: %u\n", o_hlru.size()));
}
if (o_hlru.size() > 0) {
it = o_hlru.back();
o_hlru.pop_back();
delete it->second;
o_handlers.erase(it);
}
}
it = o_handlers.insert(value_type(handler->get_id(), handler));
o_hlru.push_front(it);
}
示例8: RayCast
bool CMesh::RayCast(VECTOR4D &RayOrigin, VECTOR4D &RayDir, multimap<float, unsigned long> &Vertices, float radius)
{
// Ecuacion de la esfera con centro en el origen
// x^2 + y^2 + z^2 = r^2
for (unsigned long index = 0; index < m_Vertexes.size(); ++index)
{
if (RaySphereIntersect(RayOrigin, RayDir, m_Vertexes[index].Position, radius))
{
Vertices.insert(make_pair(Magnity(m_Vertexes[index].Position - RayOrigin), index));
}
}
return Vertices.size() != 0;
}
示例9: ShortestJobFirst
list < Attivita > ShortestJobFirst ( multimap < int, Attivita > &Activities ){
list < Attivita > A;
multimap< int, Attivita >::iterator it_ActivitiesMap;
if(!Activities.empty()){ // Ci assicuriamo che la mappa sia piena
int N = Activities.size();
for(int turnaround = 1; turnaround<= N; turnaround++){
it_ActivitiesMap = Activities.begin(); // Si posiziona sul primo elemento della mappa
int i = 1;
for ( it_ActivitiesMap = Activities.begin(); i<=turnaround; it_ActivitiesMap++ ){
A.push_back(it_ActivitiesMap->second);
i++;
}
}
}
return(A);
}
示例10: selectBestChromosome
pair<double, vector<int>> selectBestChromosome(multimap<double,vector<int>> chromosomes){
int n = chromosomes.size();
vector<int> numbers = vector_random(n);
int pos_random = Randint(0,n-2);
int max = numbers.at(pos_random);
if(max < numbers.at(pos_random+1))
max = numbers.at(pos_random+1);
multimap<double, vector<int>>::iterator it = chromosomes.begin();
for(int i = 0; i < max; i++)
it++;
return pair<double, vector<int>>((*it).first, (*it).second);
}
示例11: update_rules
void update_rules(bool is_considered[])
{
/******************************/
/* Delete all the rules which
/* were considered by the
/* left factoring.*/
/******************************/
multimap<string,string>::iterator it;
for(int i=0;i<current_non_term_rules.size();i++)
{
if(!is_considered[i])
{
it=current_non_term_rules.begin();
advance(it,i);
left_factored_rules.insert(pair<string,string>((*it).first,(*it).second));
}
}
}
示例12: getValue
double getValue(){
double value = 0.0;
if(type == Filter_Average){
vector<double>::iterator kernelIter = kernel.begin();
vector<double>::iterator dataIter = data.end();
for(int i=0; i < data.size(); i++){
double datam = data[i];
if(kernel.size() != 0){
value += datam * (*kernelIter);
kernelIter++;
if(kernelIter == kernel.end()){
kernelIter = kernel.begin();
}
}
else{
value += datam;
}
dataIter--;
}
if(type==Filter_Average && kernel.size() == 0){
value = value / (double) bufferLength;
}
}
else if(type == Filter_Median){
//select median value
int middle = medianMap.size()/2;
map<double,double>::iterator medianIter = medianMap.begin();
for(int i=0; medianIter != medianMap.end(); medianIter++,i++){
if(i==middle){
value = medianIter->second;
break;
}
}
}
return value;
}
示例13: verifyKCandidateNeighborsForward
void TiKNeighborhood::verifyKCandidateNeighborsForward (
const vector<KNeighborhoodPoint>& dataset
, KNeighborhoodPoint& point
, vector<KNeighborhoodPoint>::iterator& pointForwardIt
, bool& forwardSearch
, multimap<double, vector<KNeighborhoodPoint>::iterator, DistanceComparator>& kNeighborhood
, unsigned long k
, unsigned long& realDistanceCalculationsCounter){
double distance;
unsigned long i;
while(forwardSearch && ((pointForwardIt->distance[0] - point.distance[0]) <= point.eps)){
distance = Point::minkowskiDistance((*pointForwardIt), point, 2);
realDistanceCalculationsCounter++;
if(distance < point.eps){
i = getKeysNr(kNeighborhood, point.eps);
if((kNeighborhood.size() - i) >= (k - 1)){
kNeighborhood.erase(point.eps);
kNeighborhood.insert(pair<double, vector<KNeighborhoodPoint>::iterator>(distance, pointForwardIt));
point.eps = getMaxDistance(kNeighborhood);
}
else{
kNeighborhood.insert(pair<double, vector<KNeighborhoodPoint>::iterator>(distance, pointForwardIt));
}
}
else
if(distance == point.eps){
kNeighborhood.insert(pair<double, vector<KNeighborhoodPoint>::iterator>(distance, pointForwardIt));
}
forwardSearch = followingPoint(dataset, pointForwardIt);
}
}
示例14: cross
multimap<double, vector<int>> cross(multimap<double, vector<int>> chromosomes, double probability, vector<Data> train){
int n = chromosomes.size();
vector<int> order = vector_random(n);
vector<int> order_cross;
pair <pair<double,vector<int>>, pair<double,vector<int>>> chromosomes_songs;
multimap<double, vector<int>> chromosomed_crossed;
int n_cross = n*probability;
for(int i = 0; i < n_cross; i++){
order_cross.push_back(order.at(i));
}
for(int i = 0; i < order_cross.size()-1; i+=2) {
int c1 = order_cross.at(i);
int c2 = order_cross.at(i + 1);
multimap<double, vector<int>>::iterator it1 = chromosomes.begin(), it2 = chromosomes.begin();
for (int j = 0; j < c1; j++)
it1++;
for (int j = 0; j < c2; j++)
it2++;
chromosomes_songs = cross(*it1, *it2, train);
chromosomed_crossed.insert(chromosomes_songs.first);
chromosomed_crossed.insert(chromosomes_songs.second);
}
for(int i = n_cross-1; i < order.size(); i++){
int v = order.at(i);
multimap<double, vector<int>>::iterator it = chromosomes.begin();
for (int j = 0; j < v; j++)
it++;
chromosomed_crossed.insert(*it);
}
return chromosomed_crossed;
}
示例15: left_factor
void left_factor()
{
/*************************************/
/* Algorithm
/* Generate all the prefixes of
all the rules.
/* Take each prefix one by one
/* Check if it is the common
/* prefix of atleast two of the
/* rules.
/* Update the longest common prefix.*/
/*************************************/
bool non_terminal_used;
string RHS;
string pre;
multimap<string,string>::iterator it;
string new_left_rule;
// for(int i=0;i<prefixes.size();i++)
// {
// cout<<"Prefix:"<<prefixes[i]<<endl;
// }
string prefix_of_rhs;
int len_of_prefix;
int len_of_longest_prefix;
string longest_prefix; // keeps track of what is the longest prefix.
int longest_prefix_index=-1;
int count_of_matches; // keeps track of how many rules match for a given prefix.
string left,remaining; // left holds the prefix. // remaining holds the remaining RHS.
string new_non_terminal;
for(int n=0;n<n_t.size();n++)
{
memset(is_considered,0,sizeof(is_considered));
memset(is_matched,0,sizeof(is_matched));
prefixes.clear();
current_non_term_rules.clear();
it=rules.find(n_t[n]);
for(;it!=rules.end() && ((*it).first.compare(n_t[n])==0);it++)
{
current_non_term_rules.insert(pair<string,string>((*it).first,(*it).second));
}
for(it=current_non_term_rules.begin();it!=current_non_term_rules.end();it++)
{
pre.clear();
RHS=(*it).second;
//cout<<(*it).first<<"-->"<<(*it).second<<endl;
//cout<<RHS.size();
for(int i=0;i<RHS.size();i++)
{
pre.clear();
for(int j=0;j<=i;j++)
{
pre.push_back(RHS[j]);
}
if(find(prefixes.begin(),prefixes.end(),pre)==prefixes.end())
prefixes.push_back(pre);
}
}
// for(it=current_non_term_rules.begin();it!=current_non_term_rules.end();it++)
// {
// cout<<(*it).first<<"-->"<<(*it).second;
// }
for(int m=0;m<current_non_term_rules.size();m++)
{
//cout<<"Round "<<m<<endl;
longest_prefix.clear();
for(int i=0;i<prefixes.size();i++)
{
//cout<<"Current Prefix:"<<prefixes[i]<<endl;
len_of_prefix=prefixes[i].size();
count_of_matches=0;
for(it=current_non_term_rules.begin();it!=current_non_term_rules.end();it++)
{
// if(is_matched[it-rules.begin()])
// continue;
prefix_of_rhs.clear();
RHS.clear();
RHS=(*it).second;
//cout<<(*it).first<<"-->"<<(*it).second<<endl;
if(RHS.size()<len_of_prefix|| is_considered[distance(current_non_term_rules.begin(),it)])
continue;
for(int j=0;j<len_of_prefix;j++)
{
prefix_of_rhs.push_back(RHS[j]);
}
//cout<<"Prefix of RHS:"<<prefix_of_rhs<<endl;
if(prefix_of_rhs.compare(prefixes[i])==0)
{
//cout<<prefix_of_rhs<<"matched with "<<prefixes[i]<<endl;
//cout<<"Rule No:"<<distance(rules.begin(),it)<<endl;
is_matched[i][distance(current_non_term_rules.begin(),it)]=true;
count_of_matches++;
}
}
// cout<<"RUles after longest prefix"<<endl;
// for(it=rules.begin();it!=rules.end();it++)
// {
// cout<<"Rule No:"<<<<"-"<<(*it).first<<"-->"<<(*it).second<<endl;
// }
//cout<<"Prefix is:"<<prefixes[i]<<" has count:"<<count_of_matches<<endl;
//.........这里部分代码省略.........