当前位置: 首页>>代码示例>>C++>>正文


C++ map::rend方法代码示例

本文整理汇总了C++中std::map::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ map::rend方法的具体用法?C++ map::rend怎么用?C++ map::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::map的用法示例。


在下文中一共展示了map::rend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_free_queue

 bool thread_pool::get_free_queue(queue_ptr* out_queue) const
 {
     auto finded = std::find_if(queues.rbegin(), queues.rend(), [](const std::pair<queue::priority, queue_ptr>& iterator)
                                  {
                                      return !iterator.second->is_running;
                                  });
     
     bool is_free_queue_exist = (finded != queues.rend());
     if (is_free_queue_exist)
         *out_queue = finded->second;
     
     return  is_free_queue_exist;
 }
开发者ID:CocoaChat-UA,项目名称:dispatch,代码行数:13,代码来源:dispatch.cpp

示例2: remove_dropping_items

void inventory_selector::remove_dropping_items( player &u ) const
{
    // We iterate backwards because deletion will invalidate later indices.
    for( auto a = dropping.rbegin(); a != dropping.rend(); ++a ) {
        if( a->first < 0 ) { // weapon or armor, handled separately
            continue;
        }
        const int count = a->second;
        item &tmpit = u.inv.find_item( a->first );
        if( tmpit.count_by_charges() ) {
            long charges = tmpit.charges;
            if( count != -1 && count < charges ) {
                tmpit.charges -= count;
            } else {
                u.inv.remove_item( a->first );
            }
        } else {
            size_t max_count = u.inv.const_stack( a->first ).size();
            if( count != -1 && ( size_t )count < max_count ) {
                max_count = count;
            }
            for( size_t i = 0; i < max_count; i++ ) {
                u.inv.remove_item( a->first );
            }
        }
    }
}
开发者ID:Blaze-whatdoyoumeanitsalreadytaken,项目名称:Cataclysm-DDA,代码行数:27,代码来源:inventory_ui.cpp

示例3: replace_map

        string replace_map( const std::map< std::string, std::string > &replacements ) const
        {
            string out;

            for( size_t i = 0; i < this->size(); )
            {
                bool found = false;
                size_t match_length = 0;

                std::map< std::string, std::string >::const_reverse_iterator it;
                for( it = replacements.rbegin(); !found && it != replacements.rend(); ++it )
                {
                    const std::string &target = it->first;
                    const std::string &replacement = it->second;

                    if( match_length != target.size() )
                        match_length = target.size();

                    if( this->size() - i >= target.size() )
                    if( !std::memcmp( &this->at(int(i)), &target.at(0), (int)match_length ) )
                    {
                        i += target.size();

                        out += replacement;

                        found = true;
                    }
                }

                if( !found )
                    out += this->at(int(i++));
            }

           return out;
        }
开发者ID:r-lyeh,项目名称:wire,代码行数:35,代码来源:wire.hpp

示例4: stats_get_speed

/**
 * Get the computed average speed
 * @param thr_id int (-1 for all threads)
 */
double stats_get_speed(int thr_id, double def_speed)
{
	uint64_t gpu = thr_id;//device_map[thr_id];

	const uint64_t keymsk = 0xffULL; // last u8 is the gpu
	double speed = 0.0;
	int records = 0;

	std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
	while (i != tlastscans.rend() && records < opt_statsavg) 
	{
		if (!i->second.ignored)
		if (thr_id == -1 || (keymsk & i->first) == gpu) {
			if (i->second.hashcount > 1000) {
				speed += i->second.hashrate;
				records++;
				// applog(LOG_BLUE, "%d %x %.1f", thr_id, i->second.thr_id, i->second.hashrate);
			}
		}
		++i;
	}

	if (records)
		speed /= (double)(records);
	else
		speed = def_speed;

	if (thr_id == -1)
		speed *= (double)(opt_n_threads);

	return speed;
}
开发者ID:hinzatoni,项目名称:ccminer-lyra,代码行数:36,代码来源:stats.cpp

示例5: close

uint32_t FileWriterI::close() {
    if (baseOutfile == NULL) {
		WARNING << "ops::msole::FileWriterI::close() : file already closed";
		return RET_ERR;
    }

    // close all opened files.
    vector <GsfOutput*> :: iterator iter;
    for ( uint32_t i = 0 ; i < openFileHandler.size() ; i++) {
        GsfOutput * output = openFileHandler[i];
        if (output != NULL) {
            gsf_output_close (GSF_OUTPUT (output));
            g_object_unref (G_OBJECT (output));
        }
    }
    openFileHandler.clear();

    // close all opened directories.
    map <std::string, GsfOutput*> :: reverse_iterator rIter;
    for ( rIter = openDirList.rbegin( ) ; rIter != openDirList.rend( ) ; rIter++) {
        GsfOutput * output = openDirList[rIter->first];
        gsf_output_close (GSF_OUTPUT (output));
        g_object_unref (G_OBJECT (output));
    }
    openDirList.clear();

    baseOutfile = NULL;

	DEBUG << "ops::msole::FileWriterI::close() : file closed";

    return RET_OK;
}
开发者ID:PinSimDB,项目名称:fp-addons-sdk,代码行数:32,代码来源:ops-msole-writer.cpp

示例6: solve

int solve(const int x,
	  std::map<int, std::vector<int> >& dataset)
{
  int result = 1;

  std::map<int, std::vector<int> >::reverse_iterator it = dataset.rbegin();

  for(; it != dataset.rend(); ++it) {
    bool isIncludeF = false;

    // each vecotr element
    for (int j = 0; j < (*it).second.size(); ++j) {
      //      std::cout << (*it).first << " " << (*it).second[j] << std::endl;
      
      if (((*it).second)[j] == x) {
      	isIncludeF = true;
      	break;
      }
    }
    if (isIncludeF) { break; }
    ++result;
  }

  return result;
}
开发者ID:yuuhik,项目名称:memo,代码行数:25,代码来源:0061.cpp

示例7: printMap

void printMap(const std::map<T, T>& m, std::ostream& s = std::cout)
{
    for (typename std::map<T, T>::const_reverse_iterator it = m.rbegin(); it != m.rend(); ++it)
    {
        if (it != m.rbegin())
            s << " ";
        s << it->first << " " << it->second;
    }
    s << "\n";
}
开发者ID:grokus,项目名称:exp,代码行数:10,代码来源:zoj1261-prime-land.cpp

示例8: coeffsToDescendingWeights

static inline void coeffsToDescendingWeights(std::map<unsigned int,unsigned int>& multiSet, unsigned int weights[][2]) {                     
	std::map<unsigned int, unsigned int>::reverse_iterator  rit;
	int i = 0;
	for ( rit=multiSet.rbegin() ; rit != multiSet.rend(); rit++ ) {
		weights[i][0] = (*rit).first;
		weights[i][1] = (*rit).second;
		if(i>0) assert(weights[i-1][0]>weights[i][0]); //For debuging prpous only 
		i++;
	}
}
开发者ID:broesdecat,项目名称:Minisatid,代码行数:10,代码来源:PbSolver_convertSort.C

示例9: hashlog_get_history

/**
 * Export data for api calls
 */
int hashlog_get_history(struct hashlog_data *data, int max_records)
{
	int records = 0;

	std::map<uint64_t, hashlog_data>::reverse_iterator it = tlastshares.rbegin();
	while (it != tlastshares.rend() && records < max_records) {
		memcpy(&data[records], &(it->second), sizeof(struct hashlog_data));
		data[records].nonce = LO_DWORD(it->first);
		data[records].njobid = (uint32_t) HI_DWORD(it->first);
		records++;
		++it;
	}
	return records;
}
开发者ID:PAULINUP,项目名称:BIT,代码行数:17,代码来源:hashlog.cpp

示例10: LockMythXDisplays

void LockMythXDisplays(bool lock)
{
    if (lock)
    {
        std::map<Display*, MythXDisplay*>::iterator it;
        for (it = xdisplays.begin(); it != xdisplays.end(); ++it)
            it->second->Lock();
    }
    else
    {
        std::map<Display*, MythXDisplay*>::reverse_iterator it;
        for (it = xdisplays.rbegin(); it != xdisplays.rend(); ++it)
            it->second->Unlock();
    }
}
开发者ID:footoflove,项目名称:libmythtv-ui,代码行数:15,代码来源:mythxdisplay.cpp

示例11: stats_get_history

/**
 * Export data for api calls
 */
int stats_get_history(int thr_id, struct stats_data *data, int max_records)
{
	const uint64_t gpu = device_map[thr_id];
	const uint64_t keymsk = 0xffULL; // last u8 is the gpu
	int records = 0;

	std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
	while (i != tlastscans.rend() && records < max_records) 
	{
		if (!i->second.ignored)
			if (thr_id == -1 || (keymsk & i->first) == gpu) {
				memcpy(&data[records], &(i->second), sizeof(struct stats_data));
				records++;
			}
		++i;
	}
	return records;
}
开发者ID:hinzatoni,项目名称:ccminer-lyra,代码行数:21,代码来源:stats.cpp

示例12: ShowEmployeeList

void EmployeeListDialog::ShowEmployeeList( std::map<int, Employee*> &itsEmployees )
{
	QTableWidget *tableWidget = this->ui->tableWidgetEmployeeList;
	int count = 0;
	for ( std::map<int, Employee *>::reverse_iterator it = itsEmployees.rbegin();
		it != itsEmployees.rend();
		++it ) {
			Employee *e = it->second;
			QString strID;

			tableWidget->setItem(count,0,new QTableWidgetItem(QString::number(e->GetEmpId(), 10)));
			tableWidget->setItem(count,1,new QTableWidgetItem(e->GetName().c_str()));
			tableWidget->setItem(count,2,new QTableWidgetItem(e->GetAddress().c_str()));
			tableWidget->setItem(count,3,new QTableWidgetItem("null"));

			++count;
	}

	tableWidget->show();
}
开发者ID:ZhangYongChang,项目名称:payroll-project,代码行数:20,代码来源:employeelistdialog.cpp

示例13: Color

void Day62App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );
    
    //ROTATE THE CAMERA AROUND THE CENTRE OF THE SCENE
    mCam.setEyePoint(vec3(15 * cos(theta), 0., 15*sin(theta)));
    mCam.lookAt(vec3(0));
    
    int i = 0;
    for(std::map<float,glm::vec3>::reverse_iterator it = sorted.rbegin(); it != sorted.rend(); ++it)
    {
        gl::ScopedMatrices push;
        gl::translate(it->second);
        //gl::rotate(angleAxis(toRadians(mRotations[i]), vec3(0.,1.,0)));
        mBatch->draw();
        i++;
    }
    
    saveGif();
  
}
开发者ID:Craigson,项目名称:100days,代码行数:22,代码来源:Day62App.cpp

示例14: createFragment_

  void createFragment_(String & fragment, const Param & param, const std::map<int, std::string>& optional_mappings = (std::map<int, std::string>()))
  {

    //std::cerr << "FRAGMENT: " << fragment << "\n\n";

    // e.g.:  -input %BASENAME[%%in].mzML

    // we have to make this little detour param -> vector<String>
    // to sort the param names by length, otherwise we have a
    // problem with parameter substitution
    // i.e., if A is a prefix of B and gets replaced first, the
    // suffix of B remains and will cause trouble, e.g.: "%%out" vs. "%%out_fm"
    vector<String> param_names;
    param_names.reserve(param.size());
    for (Param::ParamIterator it = param.begin(); it != param.end(); ++it)
    {
      param_names.push_back(it->name);
    }
    // sort by length
    std::sort(param_names.begin(), param_names.end(), reverseComparator(StringSizeLess()));

    // iterate through all input params and replace with values:
    SignedSize allowed_percent(0); // filenames might contain '%', which are allowed to remain there (and even must remain)
    for (vector<String>::iterator it = param_names.begin(); it != param_names.end(); ++it)
    {
      if (!fragment.hasSubstring("%%" + *it)) continue;

      String s_new = paramToString_(param.getEntry(*it));
      allowed_percent += s_new.length() - String(s_new).substitute("%", "").length();
      //std::cerr << "IN: " << s_new << "(" << allowed_percent << "\n";
      fragment.substitute("%%" + *it, s_new);
    }
    if (fragment.hasSubstring("%%")) throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Invalid '%%' found in '" + fragment + "' after replacing all parameters!", fragment);

    // mapping replace> e.g.: %2
    // do it reverse, since %10 should precede %1
    for (std::map<int, std::string>::const_reverse_iterator it = optional_mappings.rbegin(); it != optional_mappings.rend(); ++it)
    {
      String m = String("%") + it->first;
      if (fragment.hasSubstring(m)) {
        writeDebug_(String("Replacing '") + m + "' in '" + fragment + "' by '" + it->second + "'\n", 10);
        fragment.substitute(m, it->second);
      }
    }

    // %TMP replace:
    fragment.substitute("%TMP", File::getTempDirectory());

    // %RND replace:
    fragment.substitute("%RND", String(UniqueIdGenerator::getUniqueId()));

    // %WORKINGDIR replace:
    fragment.substitute("%WORKINGDIR", tde_.working_directory);

    // %DIR% replace
    {
      QRegExp rx("%DIR\\[(.*)\\]");
      rx.setMinimal(true);
      int pos = 0;
      QString t_tmp = fragment.toQString();
      //std::cout << "fragment is:" << fragment << std::endl;
      while ((pos = rx.indexIn(t_tmp, pos)) != -1)
      {
        String value = rx.cap(1);   // param name (hopefully)
        // replace in fragment:
        QFileInfo qfi(value.toQString());
        //std::cout << "match @ " << pos << " " << value << " --> " << qfi.canonicalPath() << "\n";
        t_tmp = t_tmp.replace(String("%DIR[" + value + "]").toQString(), qfi.canonicalPath());
      }
      fragment = String(t_tmp);
      //std::cout << "NEW fragment is:" << fragment << std::endl;
    }

    // %BASENAME% replace
    {
      QRegExp rx("%BASENAME\\[(.*)\\]");
      rx.setMinimal(true);
      int pos = 0, count = 0;
      QString t_tmp = fragment.toQString();
      while ((pos = rx.indexIn(t_tmp, pos)) != -1)
      {
        //std::cout << "match @ " << pos << "\n";
        String value = rx.cap(1);   // param name (hopefully)
        // replace in fragment:
        QFileInfo qfi(value.toQString());
        //std::cout << "match @ " << pos << " " << value << " --> " << qfi.completeBaseName() << "\n";
        t_tmp = t_tmp.replace(String("%BASENAME[" + value + "]").toQString(), qfi.completeBaseName());
        ++count;
      }
      // update expected count of valid '%'
      allowed_percent -= (fragment.length() - String(fragment).substitute("%", "").length()) // original # of %
                         - (t_tmp.length() - String(t_tmp).substitute("%", "").length()) // new # of %
                         - count; // expected # of % due to %BASENAME
      fragment = String(t_tmp);
    }

    SignedSize diff = (fragment.length() - String(fragment).substitute("%", "").length()) - allowed_percent;
    //std::cerr << "allowed: " << allowed_percent << "\n" << "diff: " << diff << " in: " << fragment << "\n";
    if (diff > 0) throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Mapping still contains '%' after substitution! Did you use % instead of %%?", fragment);
    else if (diff < 0) throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Error: '%' from a filename where accidentally considered command tags! "
//.........这里部分代码省略.........
开发者ID:grosenberger,项目名称:OpenMS,代码行数:101,代码来源:GenericWrapper.cpp

示例15: unrender

void unrender()
{
	if (haloes.size() == 0) {
		return;
	}

	// Remove expired haloes
	std::map<int, effect>::iterator itor = haloes.begin();
	for(; itor != haloes.end(); ++itor ) {
		if(itor->second.expired()) {
			deleted_haloes.insert(itor->first);
		}
	}

	// Add the haloes marked for deletion to the invalidation set
	std::set<int>::const_iterator set_itor = deleted_haloes.begin();
	for(;set_itor != deleted_haloes.end(); ++set_itor) {
		invalidated_haloes.insert(*set_itor);
		haloes.find(*set_itor)->second.add_overlay_location();
	}

	// Test the multi-frame haloes whether they need an update
	for(set_itor = changing_haloes.begin();
			set_itor != changing_haloes.end(); ++set_itor) {
		if(haloes.find(*set_itor)->second.need_update()) {
			invalidated_haloes.insert(*set_itor);
			haloes.find(*set_itor)->second.add_overlay_location();
		}
	}

	// Find all halo's in a the invalidated area
	size_t halo_count;

	// Repeat until set of haloes in the invalidated area didn't change
	// (including none found) or all existing haloes are found.
	do {
		halo_count = invalidated_haloes.size();
		for(itor = haloes.begin(); itor != haloes.end(); ++itor) {
			// Test all haloes not yet in the set
			// which match one of the locations
			// 以下这个if判断的目的是判断当前这个光环, 在当前"脏"格子集合中都是否有涉及到它,
			// 如果有,也就是true,就认为该整条光环需要重绘。
			// 修改:我去掉后面判断当前脏格子集合都是是否有小涉及到脏光环,而是不管有没有涉及到都要重绘
			// 这里一方面是on_location函数要使用invalidated_locations这个我不想传的参数,
			// 另外对后面后面部队下上方/右上角检查可能恰好找出个脏的格子,到时就可能造成该光环有步及脏格子

			// if (invalidated_haloes.find(itor->first) == invalidated_haloes.end() && itor->second.on_location(invalidated_locations)) {
			if (invalidated_haloes.find(itor->first) == invalidated_haloes.end()) {

				// If found, add all locations which the halo invalidates,
				// and add it to the set
				itor->second.add_overlay_location();
				invalidated_haloes.insert(itor->first);
			}
		}
	} while (halo_count != invalidated_haloes.size() && halo_count != haloes.size());

	if(halo_count == 0) {
		return;
	}

	// 这是我注释掉的:
	//  在以上的检查haloes中,已经把invalidated_haloes光环涉及到的格子放入此次脏格子集合,那里会进行重绘,这里就没必要恢复背景了吧
	// !!!以下这个unrender不能去掉,否则光环显示不正常
	// Render the haloes:
	// iterate through all the haloes and invalidate if in set
	for(std::map<int, effect>::reverse_iterator ritor = haloes.rbegin(); ritor != haloes.rend(); ++ritor) {
		if(invalidated_haloes.find(ritor->first) != invalidated_haloes.end()) {
			ritor->second.unrender();
		}
	}

	// Really delete the haloes marked for deletion
	for(set_itor = deleted_haloes.begin(); set_itor != deleted_haloes.end(); ++set_itor) {
		// It can happen a deleted halo hasn't been rendered yet, invalidate them as well
		new_haloes.erase(*set_itor);

		changing_haloes.erase(*set_itor);
		invalidated_haloes.erase(*set_itor);
		haloes.erase(*set_itor);
	}

	deleted_haloes.clear();
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:84,代码来源:halo.cpp


注:本文中的std::map::rend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。