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


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

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


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

示例1: if

static inline int64_t next_jobid (const std::map<uint64_t, job_info_t *> &m)
{
    int64_t jobid = -1;
    if (m.empty ())
        jobid = 0;
    else if (m.rbegin ()->first < INT64_MAX)
        jobid = m.rbegin ()->first + 1;
    return jobid;
}
开发者ID:SteVwonder,项目名称:flux-sched,代码行数:9,代码来源:resource_match.cpp

示例2: 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

示例3: while

void LanguageLatex<Base>::printStaticIndexMatrix(std::ostringstream& os,
                                                 const std::string& name,
                                                 const std::map<size_t, std::map<size_t, size_t> >& values) {
    size_t m = 0;
    size_t n = 0;

    std::map<size_t, std::map<size_t, size_t> >::const_iterator it;
    std::map<size_t, size_t>::const_iterator ity2z;

    if (!values.empty()) {
        m = values.rbegin()->first + 1;

        for (it = values.begin(); it != values.end(); ++it) {
            if (!it->second.empty())
                n = std::max(n, it->second.rbegin()->first + 1);
        }
    }

    os << name << " = \\left\\{";
    size_t x = 0;
    for (it = values.begin(); it != values.end(); ++it) {
        if (it->first != x) {
            while (it->first != x) {
                os << "{},";
                x++;
            }
        }

        os << "{";

        size_t y = 0;
        for (ity2z = it->second.begin(); ity2z != it->second.end(); ++ity2z) {
            if (ity2z->first != y) {
                while (ity2z->first != y) {
                    os << "0,";
                    y++;
                }
            }

            os << ity2z->second;
            if (ity2z->first != it->second.rbegin()->first) os << ",";

            y++;
        }

        os << "}";
        if (it->first != values.rbegin()->first) os << ",";

        x++;
    }
    os << "\\right\\}" << _endEq << "% size: " << m << " x " << n << _endline;
}
开发者ID:joaoleal,项目名称:CppADCodeGen,代码行数:52,代码来源:language_latex_index_patterns.hpp

示例4: while

void LanguageC<Base>::printStaticIndexMatrix(std::ostringstream& os,
                                             const std::string& name,
                                             const std::map<size_t, std::map<size_t, size_t> >& values) {
    size_t m = 0;
    size_t n = 0;

    std::map<size_t, std::map<size_t, size_t> >::const_iterator it;
    std::map<size_t, size_t>::const_iterator ity2z;

    if (!values.empty()) {
        m = values.rbegin()->first + 1;

        for (it = values.begin(); it != values.end(); ++it) {
            if (!it->second.empty())
                n = std::max(n, it->second.rbegin()->first + 1);
        }
    }

    os << "static " << U_INDEX_TYPE << " const " << name << "[" << m << "][" << n << "] = {";
    size_t x = 0;
    for (it = values.begin(); it != values.end(); ++it) {
        if (it->first != x) {
            while (it->first != x) {
                os << "{},";
                x++;
            }
        }

        os << "{";

        size_t y = 0;
        for (ity2z = it->second.begin(); ity2z != it->second.end(); ++ity2z) {
            if (ity2z->first != y) {
                while (ity2z->first != y) {
                    os << "0,";
                    y++;
                }
            }

            os << ity2z->second;
            if (ity2z->first != it->second.rbegin()->first) os << ",";

            y++;
        }

        os << "}";
        if (it->first != values.rbegin()->first) os << ",";

        x++;
    }
    os << "};\n";
}
开发者ID:FreeScienceCommunity,项目名称:CppADCodeGen,代码行数:52,代码来源:language_c_index_patterns.hpp

示例5: lock

void GL45Backend::derezTextures() const {
    if (GLTexture::getMemoryPressure() < 1.0f) {
        return;
    }

    Lock lock(texturesByMipCountsMutex);
    if (texturesByMipCounts.empty()) {
        // No available textures to derez
        return;
    }

    auto mipLevel = texturesByMipCounts.rbegin()->first;
    if (mipLevel <= 1) {
        // No mips available to remove
        return;
    }

    GL45Texture* targetTexture = nullptr;
    {
        auto& textures = texturesByMipCounts[mipLevel];
        assert(!textures.empty());
        targetTexture = *textures.begin();
    }
    lock.unlock();
    targetTexture->derez();
}
开发者ID:kencooke,项目名称:hifi,代码行数:26,代码来源:GL45BackendTexture.cpp

示例6: 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

示例7: 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

示例8: getMyProfile

void OKSocialPluginAndroid::getMyProfile(int preferedPictureSize, void *userData, const std::vector<std::string> &additionalFields)
{
    if (!isLoggedIn())
    {
        if (_delegate)
            _delegate->onGetMyProfile({SocialPluginDelegate::Error::Type::NO_LOGIN, 0, ""}, userData, _emptyProfile);
        return;
    }

    std::string fields = "uid,first_name,last_name,email,birthday,gender";
    for (const auto &field : additionalFields)
        fields += "," + field;

    auto picturesMapIterator = _picturesMap.lower_bound(preferedPictureSize);
    const auto &pictureField = (picturesMapIterator == _picturesMap.end()) ? _picturesMap.rbegin()->second : picturesMapIterator->second;
    fields += "," + _pictureIDKey + "," + pictureField;

    cocos2d::JniMethodInfo methodInfo;
    if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, HELPER_CLASS_NAME, "getMyProfile", "(Ljava/lang/String;JLjava/lang/String;Z)V"))
    {
        jstring jFields = methodInfo.env->NewStringUTF(fields.c_str());
        jstring jPictureField = methodInfo.env->NewStringUTF(pictureField.c_str());
        methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, jFields, (jlong)userData, jPictureField, (jboolean)_debug);
        methodInfo.env->DeleteLocalRef(methodInfo.classID);
//        methodInfo.env->DeleteLocalRef(jFields); // TODO
//        methodInfo.env->DeleteLocalRef(jPictureField); // TODO
    }
}
开发者ID:newnon,项目名称:avalon,代码行数:28,代码来源:OKSocialPlugin.cpp

示例9: if

inline
std::pair<double, double> GetISInterval(double quantile,
                                        const std::map<int, size_t> &is_hist) {
  // First, obtain the sum of the values
  double S = 0;
  for (auto iter : is_hist)
    S += (double) iter.second;

  double lval = S * (1 - quantile) / 2, rval = S * (1 + quantile) / 2;
  double is_min, is_max;

  // Now, find the quantiles
  double cS = 0;
  is_min = is_hist.begin()->first;
  is_max = is_hist.rbegin()->first;
  for (auto iter : is_hist) {
    if (cS <= lval)
      is_min = iter.first;
    else if (cS <= rval)
      is_max = iter.first;
    cS += (double) iter.second;
  }

  return std::make_pair(is_min, is_max);
}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:25,代码来源:insert_size_refiner.hpp

示例10: 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

示例11: 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

示例12: 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

示例13: findDisassemblyEntry

std::map<u32,DisassemblyEntry*>::iterator findDisassemblyEntry(std::map<u32,DisassemblyEntry*>& entries, u32 address, bool exact)
{
	if (exact)
		return entries.find(address);

	if (entries.size() == 0)
		return entries.end();

	// find first elem that's >= address
	auto it = entries.lower_bound(address);
	if (it != entries.end())
	{
		// it may be an exact match
		if (isInInterval(it->second->getLineAddress(0),it->second->getTotalSize(),address))
			return it;

		// otherwise it may point to the next
		if (it != entries.begin())
		{
			it--;
			if (isInInterval(it->second->getLineAddress(0),it->second->getTotalSize(),address))
				return it;
		}
	}

	// check last entry manually
	auto rit = entries.rbegin();
	if (isInInterval(rit->second->getLineAddress(0),rit->second->getTotalSize(),address))
	{
		return (++rit).base();
	}

	// no match otherwise
	return entries.end();
}
开发者ID:ANR2ME,项目名称:ppsspp,代码行数:35,代码来源:DisassemblyManager.cpp

示例14: generateGridMap

cv::Mat MapsManager::generateGridMap(
		const std::map<int, rtabmap::Transform> & poses,
		float & xMin,
		float & yMin,
		float & gridCellSize)
{
	gridCellSize = gridCellSize_;
	cv::Mat map = util3d::create2DMapFromOccupancyLocalMaps(
			poses,
			gridMaps_,
			gridCellSize_,
			xMin, yMin,
			gridSize_,
			gridEroded_);

	// Fill unknown space around the last pose
	if(!map.empty() &&
		laserScanMaxRange_ &&
		laserScanMinAngle_ < laserScanMaxAngle_ &&
		laserScanIncrement_ &&
		poses.size())
	{
		const Transform & pose = poses.rbegin()->second;
		float roll, pitch, yaw;
		pose.getEulerAngles(roll, pitch, yaw);
		cv::Point2i start((pose.x()-xMin)/gridCellSize_ + 0.5f, (pose.y()-yMin)/gridCellSize_ + 0.5f);

		//rotate counterclockwise 180 degrees at the computed step "a" degrees
		cv::Mat rotation = (cv::Mat_<float>(2,2) << cos(laserScanIncrement_), -sin(laserScanIncrement_),
													 sin(laserScanIncrement_), cos(laserScanIncrement_));

		cv::Mat origin(2,1,CV_32F), endFirst(2,1,CV_32F);
		origin.at<float>(0) = pose.x();
		origin.at<float>(1) = pose.y();
		endFirst.at<float>(0) = laserScanMaxRange_;
		endFirst.at<float>(1) = 0;

		yaw += laserScanMinAngle_;
		cv::Mat initRotation = (cv::Mat_<float>(2,2) << cos(yaw), -sin(yaw),
														 sin(yaw), cos(yaw));

		cv::Mat endCurrent = initRotation*endFirst + origin;
		for(float a=laserScanMinAngle_; a<=laserScanMaxAngle_; a+=laserScanIncrement_)
		{
			cv::Point2i end((endCurrent.at<float>(0)-xMin)/gridCellSize_ + 0.5f, (endCurrent.at<float>(1)-yMin)/gridCellSize_ + 0.5f);
			//end must be inside the grid
			end.x = end.x < 0?0:end.x;
			end.x = end.x >= map.cols?map.cols-1:end.x;
			end.y = end.y < 0?0:end.y;
			end.y = end.y >= map.rows?map.rows-1:end.y;
			util3d::rayTrace(start, end, map, true); // trace free space

			// next point
			endCurrent = rotation*(endCurrent - origin) + origin;
		}
	}

	return map;
}
开发者ID:TSC21,项目名称:rtabmap_ros,代码行数:59,代码来源:MapsManager.cpp

示例15: addPipeHandler

			static uint64_t addPipeHandler(SignalHandler * handler)
			{
				lock.lock();
				uint64_t const id = sigpipehandlers.size() ?  (sigpipehandlers.rbegin()->first+1) : 0;
				sigpipehandlers[id] = handler;
				lock.unlock();
				return id;
			}
开发者ID:,项目名称:,代码行数:8,代码来源:


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