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


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

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


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

示例1: ltr_int_broadcast_pose

bool ltr_int_broadcast_pose(linuxtrack_full_pose_t &pose)
{
    pthread_mutex_lock(&send_mx);
    std::multimap<std::string, int>::iterator i;
    int res;
    bool checkSlaves = false;
    //Send updated pose to all clients
    //printf("Master: %g  %g  %g\n", pose.pose.raw_pitch, pose.pose.raw_yaw, pose.pose.raw_roll);
    for(i = slaves.begin(); i != slaves.end();) {
        res = ltr_int_send_data(i->second, &pose);
        if(res == -EPIPE) {
            ltr_int_log_message("Slave @socket %d left!\n", i->second);
            close(i->second);
            i->second = -1;
            slaves.erase(i++);
            checkSlaves = true;
        } else {
            ++i;
        }
    }
    if(checkSlaves && (slaves.size() == 0)) {
        no_slaves = true;
    }
    pthread_mutex_unlock(&send_mx);
    return true;
}
开发者ID:balthisar,项目名称:linuxtrack,代码行数:26,代码来源:ltr_srv_master.cpp

示例2: Shutdown

void AMQPAbstractPublishNotifier::Shutdown()
{
    LogPrint("amqp", "amqp: Shutdown notifier %s at %s\n", GetType(), GetAddress());

    int count = mapPublishNotifiers.count(address);

    // remove this notifier from the list of publishers using this address
    typedef std::multimap<std::string, AMQPAbstractPublishNotifier*>::iterator iterator;
    std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(address);

    for (iterator it = iterpair.first; it != iterpair.second; ++it) {
        if (it->second == this) {
            mapPublishNotifiers.erase(it);
            break;
        }
    }

    // terminate the connection if this is the last publisher using this address
    if (count == 1) {
        handler_->terminate();
        if (thread_.get() != nullptr) {
            if (thread_->joinable()) {
                thread_->join();
            }
        }
    }
}
开发者ID:Whiteblock,项目名称:zcash,代码行数:27,代码来源:amqppublishnotifier.cpp

示例3: flush_immediate_sync

 void flush_immediate_sync() {
   auto seq_no = processor_.max_finished_seq_no();
   for (auto it = immediate_sync_promises_.begin(), end = immediate_sync_promises_.end();
        it != end && it->first <= seq_no; it = immediate_sync_promises_.erase(it)) {
     do_immediate_sync(std::move(it->second));
   }
 }
开发者ID:anhdocphys,项目名称:td,代码行数:7,代码来源:ConcurrentBinlog.cpp

示例4: updateEvent

    void updateEvent(int id, int idx, float val, int activate_cmd)
    {
        idmap_t id_iter = idmap.find(id);
        if (id_iter != idmap.end())
        {
            //this is a new id
            iter_t e_iter = id_iter->second;
            Event * e = e_iter->second;
            int onset = e->onset;
            e->update(idx, val);
            e->activate_cmd(activate_cmd);
            if (onset != e->onset)
            {
                ev.erase(e_iter);

                e_iter = ev.insert(pair_t(e->onset, e));

                //TODO: optimize by thinking about whether to do ev_pos = e_iter
                ev_pos = ev.upper_bound( tick_prev );
                idmap[id] = e_iter;
            }
        }
        else
        {
            g_log->printf(1, "%s unknown note %i\n", __FUNCTION__, id);
        }
    }
开发者ID:godiard,项目名称:music-keyboard-activity,代码行数:27,代码来源:aclient.cpp

示例5: merge_recommended_queries

  void query_recommender::merge_recommended_queries(std::multimap<double,std::string,std::less<double> > &related_queries,
      hash_map<const char*,double,hash<const char*>,eqstr> &update)
  {
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator hit;
    std::multimap<double,std::string,std::less<double> >::iterator mit
    = related_queries.begin();
    while(mit!=related_queries.end())
      {
        std::string rquery = (*mit).second;
        if ((hit = update.find(rquery.c_str()))!=update.end())
          {
            (*hit).second = std::min((*mit).first,(*hit).second);
            std::multimap<double,std::string,std::less<double> >::iterator mit2 = mit;
            ++mit;
            related_queries.erase(mit2);
          }
        else ++mit;
      }
    hit = update.begin();
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator chit;
    while(hit!=update.end())
      {
        related_queries.insert(std::pair<double,std::string>((*hit).second,std::string((*hit).first)));
        chit = hit;
        ++hit;
        free_const((*chit).first);
      }

  }
开发者ID:Psycojoker,项目名称:seeks,代码行数:29,代码来源:query_recommender.cpp

示例6: DeletePersistentData

bool World::DeletePersistentData(const PersistentDataItem &item)
{
    int id = item.raw_id();
    if (id > -100)
        return false;
    if (!BuildPersistentCache())
        return false;

    stl::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();

    auto eqrange = persistent_index.equal_range(item.key());

    for (auto it2 = eqrange.first; it2 != eqrange.second; )
    {
        auto it = it2; ++it2;

        if (it->second != -id)
            continue;

        persistent_index.erase(it);

        int idx = binsearch_index(hfvec, id);

        if (idx >= 0) {
            delete hfvec[idx];
            hfvec.erase(hfvec.begin()+idx);
        }

        return true;
    }

    return false;
}
开发者ID:mstram,项目名称:dfhack-40d,代码行数:33,代码来源:World.cpp

示例7: Run

    virtual void Run()
    {
        now = v8::base::OS::TimeCurrentMillis();

        while (1)
        {
            AsyncEvent *p;
            std::multimap<double, AsyncEvent *>::iterator e;

            wait();

            now = v8::base::OS::TimeCurrentMillis();

            while (1)
            {
                p = s_acSleep.get();
                if (p == NULL)
                    break;

                s_tms.insert(std::make_pair(now + p->result(), p));
            }

            while (1)
            {
                e = s_tms.begin();
                if (e == s_tms.end())
                    break;
                if (e->first > now)
                    break;

                e->second->apost(0);
                s_tms.erase(e);
            }
        }
    }
开发者ID:Andrew-Zhang,项目名称:fibjs,代码行数:35,代码来源:fbFiber.cpp

示例8: Timer

    static void PASCAL Timer(unsigned int uTimerID, unsigned int uMsg,
                             DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
    {
        AsyncEvent *p;
        double tm;
        std::multimap<double, AsyncEvent *>::iterator e;

        while (1)
        {
            p = s_acSleep.get();
            if (p == NULL)
                break;

            tm = s_time + s_now + p->result();
            s_tms.insert(std::make_pair(tm, p));
        }

        atom_xchg(&s_now, (int)(v8::internal::OS::TimeCurrentMillis() - s_time));

        while (1)
        {
            e = s_tms.begin();
            if (e == s_tms.end())
                break;
            if (e->first > s_time + s_now)
                break;

            e->second->apost(0);
            s_tms.erase(e);
        }
    }
开发者ID:cwyiu,项目名称:fibjs,代码行数:31,代码来源:fbFiber.cpp

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

示例10: Shutdown

void CZMQAbstractPublishNotifier::Shutdown()
{
    assert(psocket);

    int count = mapPublishNotifiers.count(address);

    // remove this notifier from the list of publishers using this address
    typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
    std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(address);

    for (iterator it = iterpair.first; it != iterpair.second; ++it)
    {
        if (it->second==this)
        {
            mapPublishNotifiers.erase(it);
            break;
        }
    }

    if (count == 1)
    {
        LogPrint("zmq", "Close socket at address %s\n", address);
        int linger = 0;
        zmq_setsockopt(psocket, ZMQ_LINGER, &linger, sizeof(linger));
        zmq_close(psocket);
    }

    psocket = 0;
}
开发者ID:CryptoDJ,项目名称:DarkSilk-Release-Candidate,代码行数:29,代码来源:zmqpublishnotifier.cpp

示例11: removeAlgorithm

/**
 * @param name A string containing the algorithm name
 * @param version The version to remove. -1 indicates all instances
 * @param typedLoaders A map of names to version numbers
 **/
void FileLoaderRegistryImpl::removeAlgorithm(
    const std::string &name, const int version,
    std::multimap<std::string, int> &typedLoaders) {
  if (version == -1) // remove all
  {
    typedLoaders.erase(name);
  } else // find the right version
  {
    auto range = typedLoaders.equal_range(name);
    for (auto ritr = range.first; ritr != range.second; ++ritr) {
      if (ritr->second == version) {
        typedLoaders.erase(ritr);
        break;
      }
    }
  }
}
开发者ID:DiegoMonserrat,项目名称:mantid,代码行数:22,代码来源:FileLoaderRegistry.cpp

示例12: deleteGame

void GameDB::deleteGame(std::multimap<Reference<Team>, Reference<Game>>& map, Reference<Team> team, Reference<Game> game) {
  auto range = map.equal_range(team);
  for (auto i = range.first; i != range.second; ++i) {
    if (i->second == game) {
      map.erase(i);
      return;
    }
  }
}
开发者ID:tommywalsh,项目名称:team-rank,代码行数:9,代码来源:games.cpp

示例13: removeExampleHandler

 	bool removeExampleHandler (T eventName, Handle handler) {
		auto ret = map.equal_range(eventName);
		for(auto it = ret.first;it != ret.second;++it) {
			if(it->second == handler) {
				it = map.erase(it);
				return true;
			}
		}
		return false;
	}
开发者ID:Rush,项目名称:cpp-EventEmitter,代码行数:10,代码来源:EventEmitter.sane.hpp

示例14: operator

    // msgpack::type::MAP is converted to std::multimap, not std::map.
    void operator()(std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref>& v) const {
        std::cout << "match map" << std::endl;
        std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref>::iterator it = v.begin();
        std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref>::iterator end = v.end();
        while(it != end) {
            boost::string_ref const& key = it->first.as_boost_string_ref();
            if (key == "name") {
                boost::string_ref const& value = it->second.as_boost_string_ref();
                if (value == "Takatoshi Kondo") {
                    // You can add values to msgpack::type::variant_ref.
                    v.insert(
                        std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref>::value_type(
                            "role",
                            "msgpack-c committer"
                        )
                    );
                }
                ++it;
            }
            else if (key == "age") {
                // You can remove key-value pair from msgpack::type::variant_ref

#if defined(MSGPACK_USE_CPP03)
                v.erase(it++);
#else  // defined(MSGPACK_USE_CPP03)
#  if MSGPACK_LIB_STD_CXX
                it = v.erase(std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref>::const_iterator(it));
#  else  // MSGPACK_LIB_STD_CXX
                it = v.erase(it);
#  endif // MSGPACK_LIB_STD_CXX
#endif // defined(MSGPACK_USE_CPP03)
            }
            else if (key == "address") {
                // When you want to append string
                // "Tokyo" -> "Tokyo, JAPAN"
                // Use msgpack::type::variant instead of msgpack::type::variant_ref
                // or do as follows:
                boost::string_ref const& value = it->second.as_boost_string_ref();
                it->second = std::string(&value.front(), value.size()) + ", JAPAN";
                ++it;
            }
        }
    }
开发者ID:ArjunKhanna,项目名称:msgpack-c,代码行数:44,代码来源:msgpack_variant_mapbased.cpp

示例15: sort_by_location

 static void sort_by_location(std::multimap<std::string, Species> location_map,
         std::vector<Species>& species, const std::string location="")
 {
     std::multimap<std::string, Species>::iterator itr;
     while ((itr = location_map.find(location)) != location_map.end())
     {
         const Species sp((*itr).second);
         species.push_back(sp);
         sort_by_location(location_map, species, sp.serial());
         location_map.erase(itr);
     }
 }
开发者ID:kozo2,项目名称:ecell4,代码行数:12,代码来源:LatticeSpaceHDF5Writer.hpp


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