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


C++ multimap::lower_bound方法代码示例

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


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

示例1: GetPersistentData

void World::GetPersistentData(std::vector<PersistentDataItem> *vec, const std::string &key, bool prefix)
{
    vec->clear();

    if (!BuildPersistentCache())
        return;

    auto eqrange = persistent_index.equal_range(key);

    if (prefix)
    {
        if (key.empty())
        {
            eqrange.first = persistent_index.begin();
            eqrange.second = persistent_index.end();
        }
        else
        {
            std::string bound = key;
            if (bound[bound.size()-1] != '/')
                bound += "/";
            eqrange.first = persistent_index.lower_bound(bound);

            bound[bound.size()-1]++;
            eqrange.second = persistent_index.lower_bound(bound);
        }
    }

    for (auto it = eqrange.first; it != eqrange.second; ++it)
    {
        auto hfig = df::historical_figure::find(-it->second);
        if (hfig && hfig->name.has_name)
            vec->push_back(dataFromHFig(hfig));
    }
}
开发者ID:mstram,项目名称:dfhack-40d,代码行数:35,代码来源:World.cpp

示例2: while

std::vector<std::multimap<ReducedFraction, MidiChord>::const_iterator>
findChordsForTimeRange(
            int voice,
            const ReducedFraction &onTime,
            const ReducedFraction &offTime,
            const std::multimap<ReducedFraction, MidiChord> &chords,
            const ReducedFraction &maxChordLength)
      {
      std::vector<std::multimap<ReducedFraction, MidiChord>::const_iterator> result;

      if (chords.empty())
            return result;

      auto it = chords.lower_bound(offTime);
      if (it == chords.begin())
            return result;
      --it;

      while (it->first + maxChordLength > onTime) {
            const MidiChord &chord = it->second;
            if (chord.voice == voice) {
                  const auto chordInterval = std::make_pair(it->first, maxNoteOffTime(chord.notes));
                  const auto durationInterval = std::make_pair(onTime, offTime);

                  if (MidiTuplet::haveIntersection(chordInterval, durationInterval))
                        result.push_back(it);
                  }
            if (it == chords.begin())
                  break;
            --it;
            }

      return result;
      }
开发者ID:chenlung,项目名称:MuseScore,代码行数:34,代码来源:importmidi_chord.cpp

示例3: GFGoodSell

void __stdcall GFGoodSell(const struct SGFGoodSellInfo &gsi, unsigned int iClientID)
{
	returncode = DEFAULT_RETURNCODE;

	uint iBase;
	pub::Player::GetBase(iClientID, iBase);

	multimap<uint, CARGO_MISSION>::iterator start = set_mapCargoMissions.lower_bound(iBase);
	multimap<uint, CARGO_MISSION>::iterator end = set_mapCargoMissions.upper_bound(iBase);
	for (; start != end; ++start)
	{
		if (start->second.item == gsi.iArchID)
		{
			if (start->second.curr_amount < start->second.required_amount)
			{
				int needed = start->second.required_amount - start->second.curr_amount;
				if (needed > gsi.iCount)
				{
					start->second.curr_amount += gsi.iCount;
					needed = start->second.required_amount - start->second.curr_amount;
					PrintUserCmdText(iClientID, L"%d units remaining to complete mission objective", needed);
				}
				else
				{
					PrintUserCmdText(iClientID, L"Mission objective completed",needed);
				}
			}
		}
	}
}
开发者ID:HeIIoween,项目名称:FLHook,代码行数:30,代码来源:Main.cpp

示例4: malloc

void *MemoryPool::pop(size_t s, int loc) {
    void *addr = nullptr;

    if ((s > MIN_BLOCK_SIZE) && (s < MAX_BLOCK_SIZE)) {
        locker_.lock();

        // find MemoryPool block which is not smaller than demand size
        auto pt = pool_.lower_bound(s);

        if (pt != pool_.end()) {
            size_t ts = 0;
            std::tie(ts, addr) = *pt;
            if (ts < s * 2) {
                s = ts;
                pool_.erase(pt);
                pool_depth_ -= s;
            } else {
                addr = nullptr;
            }
        }
        locker_.unlock();
    }

    if (addr == nullptr) {
        try {
#ifdef __CUDA__
            SP_DEVICE_CALL(cudaMallocManaged(&addr, s));
#else
            addr = malloc(s);
#endif
        } catch (std::bad_alloc const &error) { THROW_EXCEPTION_BAD_ALLOC(s); }
    }
    return addr;
}
开发者ID:simpla-fusion,项目名称:SimPla,代码行数:34,代码来源:memory.cpp

示例5: search

    void search(const std::string &now, const std::string &end, const std::vector<std::string> &path, const std::multimap<std::string, std::string> &word_map, std::vector<std::vector<std::string> > &ans, int min_size)
    {
		if (now == end)
		{
			ans.push_back(path);
			if (path.size() < min_size)
			{
				min_size = path.size();
			}
			return;
		}
		if (path.size() > min_size)
		{
			return;
		}
		std::multimap<std::string, std::string>::const_iterator low = word_map.lower_bound(now);
		std::multimap<std::string, std::string>::const_iterator up = word_map.upper_bound(now);
		for (std::multimap<std::string, std::string>::const_iterator it = low; it != up; ++ it)
		{
			if (std::find(path.begin(), path.end(), it->second) == path.end())
			{
				std::vector<std::string> mypath = path;
				mypath.push_back(it->second);
				search(it->second, end, mypath, word_map, ans, min_size);
			}
		}
	}
开发者ID:FeiZhan,项目名称:Algo-Collection,代码行数:27,代码来源:Word+Ladder+II.cpp

示例6: LoadLadspaEffect

static void LoadLadspaEffect(wxSortedArrayString &uniq, wxString fname,
                             DL_Array &dls)
{
   wxLogNull logNo;
   LADSPA_Descriptor_Function mainFn = NULL;

   // Since we now have builtin VST support, ignore the VST bridge as it
   // causes duplicate menu entries to appear.
   wxFileName f(fname);
   if (f.GetName().CmpNoCase(wxT("vst-bridge")) == 0) {
      return;
   }

   // As a courtesy to some plug-ins that might be bridges to
   // open other plug-ins, we set the current working
   // directory to be the plug-in's directory.

   wxString saveOldCWD = ::wxGetCwd();
   wxString prefix = ::wxPathOnly(fname);
   ::wxSetWorkingDirectory(prefix);

   wxDynamicLibrary* pDLL = new wxDynamicLibrary();
   dls.push_back(pDLL);
   if (pDLL && pDLL->Load(fname, wxDL_LAZY)) {
      mainFn = (LADSPA_Descriptor_Function)(pDLL->GetSymbol(wxT(descriptorFnName)));
   }

   if (mainFn) {
      int index = 0;
      const LADSPA_Descriptor *data;

      data = mainFn(index);
      while(data) {

         wxString uniqid = wxString::Format(wxT("%08x-%s"), data->UniqueID, LAT1CTOWX(data->Label).c_str());
         if (uniq.Index(uniqid) == wxNOT_FOUND) {
            uniq.Add(uniqid);
            std::set<wxString> categories;

#if defined(USE_LIBLRDF) && defined(EFFECT_CATEGORIES)
            std::multimap<unsigned long, wxString>::const_iterator iter;
            iter = gPluginCategories.lower_bound(data->UniqueID);
            for ( ; (iter != gPluginCategories.end() &&
                     iter->first == data->UniqueID); ++iter)
               categories.insert(iter->second);
#endif

            LadspaEffect *effect = new LadspaEffect(data, categories);
            EffectManager::Get().RegisterEffect(effect);
         }
            
         // Get next plugin
         index++;
         data = mainFn(index);            
      }
   }

   ::wxSetWorkingDirectory(saveOldCWD);
}
开发者ID:Cactuslegs,项目名称:audacity-of-nope,代码行数:59,代码来源:LoadLadspa.cpp

示例7: query

 int query(float min_price, float max_price, time_t min_timestamp, time_t max_timestamp) {
      std::multimap<float, Row*>::iterator it1 = price_row_mulmap.lower_bound(min_price);
      std::multimap<float, Row*>::iterator it2 = price_row_mulmap.upper_bound(max_price);
      int count = 0;
      for(; it1 != it2; it1++) {
          if(it1->second->timestamp >= min_timestamp && it1->second->timestamp <= max_timestamp) count++;
      }
      return count;
 }  
开发者ID:trumanz,项目名称:cpp-learning,代码行数:9,代码来源:table_search.cpp

示例8:

std::multimap<ReducedFraction, MidiChord>::const_iterator
findFirstChordInRange(const std::multimap<ReducedFraction, MidiChord> &chords,
                      const ReducedFraction &startRangeTick,
                      const ReducedFraction &endRangeTick)
      {
      auto iter = chords.lower_bound(startRangeTick);
      if (iter != chords.end() && iter->first >= endRangeTick)
            iter = chords.end();
      return iter;
      }
开发者ID:chenlung,项目名称:MuseScore,代码行数:10,代码来源:importmidi_chord.cpp

示例9: recur_connect_e

// starting form a list of elements, returns
// lists of lists that are all simply connected
static void recur_connect_e (const MEdge &e,
                             std::multimap<MEdge,MElement*,Less_Edge> &e2e,
                             std::set<MElement*> &group,
                             std::set<MEdge,Less_Edge> &touched){
  if (touched.find(e) != touched.end())return;
  touched.insert(e);
  for (std::multimap <MEdge,MElement*,Less_Edge>::iterator it = e2e.lower_bound(e);
         it != e2e.upper_bound(e) ; ++it){
    group.insert(it->second);
    for (int i=0;i<it->second->getNumEdges();++i){
      recur_connect_e (it->second->getEdge(i),e2e,group,touched);
    }
  }
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:16,代码来源:multiscalePartition.cpp

示例10: checkOptions

 void checkOptions(const DeckKeyword& keyword, std::multimap<std::string , PartiallySupported<T> >& map, const ParseContext& parseContext, ErrorGuard& errorGuard)
 {
     // check for partially supported keywords.
     typename std::multimap<std::string, PartiallySupported<T> >::iterator it, itlow, itup;
     itlow = map.lower_bound(keyword.name());
     itup  = map.upper_bound(keyword.name());
     for (it = itlow; it != itup; ++it) {
         const auto& record = keyword.getRecord(0);
         if (record.getItem(it->second.item).template get<T>(0) != it->second.item_value) {
             std::string msg = "For keyword '" + it->first + "' only value " + boost::lexical_cast<std::string>(it->second.item_value)
                 + " in item " + it->second.item + " is supported by flow.\n"
                 + "In file " + keyword.getFileName() + ", line " + std::to_string(keyword.getLineNumber()) + "\n";
             parseContext.handleError(ParseContext::SIMULATOR_KEYWORD_ITEM_NOT_SUPPORTED, msg, errorGuard);
         }
     }
 }
开发者ID:OPM,项目名称:opm-simulators,代码行数:16,代码来源:MissingFeatures.cpp

示例11: recur_connect

static void recur_connect(MVertex *v,
                          std::multimap<MVertex*,MEdge> &v2e,
                          std::set<MEdge,Less_Edge> &group,
                          std::set<MVertex*> &touched)
{
  if (touched.find(v) != touched.end())return;

  touched.insert(v);
  for (std::multimap <MVertex*,MEdge>::iterator it = v2e.lower_bound(v);
       it != v2e.upper_bound(v) ; ++it){
    group.insert(it->second);
    for (int i=0;i<it->second.getNumVertices();++i){
      recur_connect (it->second.getVertex(i),v2e,group,touched);
    }
  }

}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:17,代码来源:multiscalePartition.cpp

示例12: GFGoodBuy

void __stdcall GFGoodBuy(struct SGFGoodBuyInfo const &gbi, unsigned int iClientID)
{
	uint iBase;
	pub::Player::GetBase(iClientID, iBase);

	multimap<uint, CARGO_MISSION>::iterator start = set_mapCargoMissions.lower_bound(iBase);
	multimap<uint, CARGO_MISSION>::iterator end = set_mapCargoMissions.upper_bound(iBase);
	for (; start != end; ++start)
	{
		if (start->second.item == gbi.iGoodID)
		{
			start->second.curr_amount -= gbi.iCount;
			if (start->second.curr_amount < 0)
			{
				start->second.curr_amount = 0;
			}
		}
	}
}
开发者ID:HeIIoween,项目名称:FLHook,代码行数:19,代码来源:Main.cpp

示例13: recurConnectByMEdge

static void recurConnectByMEdge(const MEdge &e,
				std::multimap<MEdge, MTriangle*, Less_Edge> &e2e,
				std::set<MTriangle*> &group,
				std::set<MEdge, Less_Edge> &touched,
				std::set<MEdge, Less_Edge> &theCut)
{
  if (touched.find(e) != touched.end()) return;
  touched.insert(e);
  for (std::multimap <MEdge, MTriangle*, Less_Edge>::iterator it = e2e.lower_bound(e);
       it != e2e.upper_bound(e); ++it){
    group.insert(it->second);
    for (int i = 0; i < it->second->getNumEdges(); ++i){
      MEdge me = it->second->getEdge(i);
      if (theCut.find(me) != theCut.end()){
	touched.insert(me); //break;
      }
      else recurConnectByMEdge(me, e2e, group, touched, theCut);
    }
  }
}
开发者ID:feelpp,项目名称:debian-gmsh,代码行数:20,代码来源:CenterlineField.cpp

示例14: ShipDestroyed

void __stdcall ShipDestroyed(DamageList *_dmg, DWORD *ecx, uint iKill)
{
	returncode = DEFAULT_RETURNCODE;

	if (iKill)
	{
		CShip *cship = (CShip*)ecx[4];

		int iRep;
		pub::SpaceObj::GetRep(cship->get_id(), iRep);
		
		uint iAff;
		pub::Reputation::GetAffiliation(iRep, iAff);

		Vector vPos;
		vPos.x = cship->fPosX;
		vPos.y = cship->fPosY;
		vPos.z = cship->fPosZ;
		string scSector = VectorToSectorCoord(cship->iSystem, vPos);

		multimap<uint, NPC_MISSION>::iterator start = set_mapNpcMissions.lower_bound(iAff);
		multimap<uint, NPC_MISSION>::iterator end = set_mapNpcMissions.upper_bound(iAff);
		for (; start != end; ++start)
		{
			if (start->second.system == cship->iSystem)
			{
				if (start->second.sector.length() && start->second.sector != scSector)
					continue;

				if (start->second.curr_amount < start->second.required_amount)
				{
					start->second.curr_amount++;
					// PrintUserCmdText(iClientID, L"%d ships remaining to destroy to complete mission objective", needed);
				}
			}
		}
	}
}
开发者ID:HeIIoween,项目名称:FLHook,代码行数:38,代码来源:Main.cpp

示例15: detectTuplets

std::vector<TupletInfo> detectTuplets(
            const std::multimap<ReducedFraction, MidiChord>::iterator &startBarChordIt,
            const std::multimap<ReducedFraction, MidiChord>::iterator &endBarChordIt,
            const ReducedFraction &startBarTick,
            const ReducedFraction &barFraction,
            std::multimap<ReducedFraction, MidiChord> &chords,
            const ReducedFraction &basicQuant,
            int barIndex)
      {
      const auto divLengths = Meter::divisionsOfBarForTuplets(barFraction);

      std::vector<TupletInfo> tuplets;
      int id = 0;
      const auto tol = basicQuant / 2;

      for (const auto &divLen: divLengths) {
            const auto tupletNumbers = findTupletNumbers(divLen, barFraction);
            const auto div = barFraction / divLen;
            const int divCount = div.numerator() / div.denominator();

            for (int i = 0; i != divCount; ++i) {
                  const auto startDivTime = startBarTick + divLen * i;
                  const auto endDivTime = startBarTick + divLen * (i + 1);
                              // check which chords can be inside tuplet period
                              // [startDivTime - tol, endDivTime]
                  const auto startDivTimeWithTol = qMax(startBarTick, startDivTime - tol);
                  auto startDivChordIt = MChord::findFirstChordInRange(startDivTimeWithTol, endDivTime,
                                                                       startBarChordIt, endBarChordIt);
                  if (startDivChordIt == endBarChordIt)
                        continue;

                  Q_ASSERT_X(!startDivChordIt->second.isInTuplet,
                             "MIDI tuplets: findTuplets", "Tuplet chord has been already used");

                              // end iterator, as usual, point to the next - invalid chord
                  auto endDivChordIt = chords.lower_bound(endDivTime);
                  if (!isNextBarOwnershipOk(startDivChordIt, endDivChordIt, chords, barIndex))
                        continue;
                              // try different tuplets, nested tuplets are not allowed
                              // here chords from next bar can be captured
                              // if their on time < next bar start
                  for (const auto &tupletNumber: tupletNumbers) {
                        if (!isTupletLenAllowed(divLen, tupletNumber, startDivChordIt, endDivChordIt,
                                                basicQuant)) {
                              continue;
                              }
                        auto tupletInfo = findTupletApproximation(divLen, tupletNumber,
                                             basicQuant, startDivTime, startDivChordIt, endDivChordIt);

                        const auto &opers = midiImportOperations.data()->trackOpers;
                        const int currentTrack = midiImportOperations.currentTrack();

                        if (opers.simplifyDurations.value(currentTrack)) {
                              if (!haveChordsInTheMiddleBetweenTupletChords(
                                                startDivChordIt, endDivChordIt, tupletInfo)) {
                                    detectStaccato(tupletInfo);
                                    }
                              }
                        tupletInfo.sumLengthOfRests = findSumLengthOfRests(tupletInfo, startBarTick);

                        if (!isTupletAllowed(tupletInfo))
                              continue;
                        tupletInfo.id = id++;
                        tuplets.push_back(tupletInfo);   // tuplet found
                        }      // next tuplet type
                  }
            }

      return tuplets;
      }
开发者ID:CammyVee,项目名称:MuseScore,代码行数:70,代码来源:importmidi_tuplet_detect.cpp


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