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


C++ multiset::begin方法代码示例

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


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

示例1: greater_than_strict

inline bool greater_than_strict(std::multiset< int > multiset1, std::multiset< int > multiset2, unsigned int id1, unsigned int id2){

			std::multiset< int >::iterator multiset1_itr = multiset1.begin(), multiset2_itr = multiset2.begin();
			int fi,fj;

 			for ( fi = multiset1.size(),fj = multiset2.size(); fi>0 && fj>0 ;fi--,fj--)
			{
 
				if (*multiset1_itr == *multiset2_itr)
				{
					multiset1_itr++ , multiset2_itr++;
				}
				else {
				
 					//return *multiset1_itr < *multiset2_itr ; //ascending
					return *multiset1_itr > *multiset2_itr ;//descending
				}
			}

			//Haven't returned yet and the foor loop exited, so that means the two input multiset have equal entries atleast the common portions 
 			if (fi==fj)
 			{
				//If they are equal, that means the relevance multiset is exactly the same, in that case we need to enforce stricter ordering based on node ids
				return id1> id2; //Descending
 			}
			//return (fi<fj);//asecending
			return (fi>fj);//descending

};
开发者ID:atripathy86,项目名称:srn,代码行数:29,代码来源:Node.hpp

示例2: save

bool Serialization::save(std::multiset<Event *, Cmp_event_day> &events)
{
    //Save file to disk
    QFile file("events.txt");
    if(!file.open(QIODevice::WriteOnly))
    {
        qDebug() << "Could not open file";
        return false;
    }

    //create output stream
    QDataStream out (&file);
    //set output version
    out.setVersion(QDataStream::Qt_4_8);

    //iteration
    std::multiset<Event *>::iterator it;
    for ( it=events.begin() ; it != events.end(); it++ )
        out << **it;

    //Finito! flush the stream to the file and close
    file.flush();
    file.close();
    return true;
}
开发者ID:CDargis,项目名称:Roto-Cal,代码行数:25,代码来源:serialization.cpp

示例3: A

/**
 A = x1 or x2 or ... xn
 create cnf to create an Equility.
 * @brief Solver::SatBaseClass::createTseitinOr
 * @param vars x1, ..., xn
 * @return A
*/
uint Solver::SatBaseClass::createTseitinOr(std::multiset<literal>& vars){
    if(vars.size() == 0) return getFalseVar();
    if(vars.size() == 1) return (*vars.begin()).varId;
    uint A(++countVars);
// if A is true, then one of the xi must be true
    result << "-" << A << " ";
    for(const literal& t: vars){
        if(t.positiv){
            result << t.varId << " ";
        }else {
            result << "-" << t.varId << " ";
        }
    }
    result << "0" << std::endl;
    countClausel++;

// if one of the xi is true then A is true
    for(const literal& t: vars){
        result << A << " ";
        if(t.positiv){
            result << "-" << t.varId << " 0" << std::endl;
        } else {
            result << t.varId << " 0" << std::endl;
        }
        countClausel++;
    }
    return A;
}
开发者ID:Fettpet,项目名称:Modulogame,代码行数:35,代码来源:satbaseclass.cpp

示例4: populateMultiset

void populateMultiset(std::multiset<sdEvent*, sdEventCompare> eventSet) {
    std::multiset <sdEvent*, sdEventCompare>::iterator eit = eventSet.begin();
    while(eit != eventSet.end()) {
        sdEvent* event = *eit;
        std::cout << "   " << event->getTime() << ":" << event->getDescriptorAsString() << " " << event->getValueAsString() << std::endl;
        eit++;
    }
}
开发者ID:rodrigodzf,项目名称:libspatdif-android,代码行数:8,代码来源:sdExtensionTest.cpp

示例5: main

int main()
{
    typedef test_compare<std::less<int> > C;
    const std::multiset<int, C> m(C(3));
    assert(m.empty());
    assert(m.begin() == m.end());
    assert(m.key_comp() == C(3));
    assert(m.value_comp() == C(3));
}
开发者ID:CaseyCarter,项目名称:libcxx,代码行数:9,代码来源:compare.pass.cpp

示例6: equal_and_greater

//if return is 0 then neither greater or equal, if returned 1 then equal, if 2 then greater
inline int equal_and_greater(std::multiset< int > multiset1, std::multiset< int > multiset2){

			std::multiset< int >::iterator multiset1_itr = multiset1.begin(), multiset2_itr = multiset2.begin();
			int fi,fj;
 
			for ( fi = multiset1.size(),fj = multiset2.size(); fi>0 && fj>0 ;fi--,fj--)
			{
				if (*multiset1_itr == *multiset2_itr)
				{
					multiset1_itr++ ; multiset2_itr++;  
				}
				else {
					return ((*multiset1_itr > *multiset2_itr) ? 2 : (*multiset1_itr == *multiset2_itr)?  1 : 0) ;
				}
 			}
			
			return (fi < fj) ? 0: (fi > fj) ? 2: 1;

};
开发者ID:atripathy86,项目名称:srn,代码行数:20,代码来源:Node.hpp

示例7: PrettyPrint

 inline std::string PrettyPrint(const std::multiset<T>& settoprint, const bool add_delimiters=false, const std::string& separator=", ")
 {
     std::ostringstream strm;
     if (settoprint.size() > 0)
     {
         if (add_delimiters)
         {
             strm << "(";
             typename std::multiset<T, Compare, Allocator>::const_iterator itr;
             for (itr = settoprint.begin(); itr != settoprint.end(); ++itr)
             {
                 if (itr != settoprint.begin())
                 {
                     strm << separator << PrettyPrint(*itr, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(*itr, add_delimiters, separator);
                 }
             }
             strm << ")";
         }
         else
         {
             typename std::multiset<T, Compare, Allocator>::const_iterator itr;
             for (itr = settoprint.begin(); itr != settoprint.end(); ++itr)
             {
                 if (itr != settoprint.begin())
                 {
                     strm << separator << PrettyPrint(*itr, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(*itr, add_delimiters, separator);
                 }
             }
         }
     }
     return strm.str();
 }
开发者ID:orthez,项目名称:arc_utilities,代码行数:40,代码来源:pretty_print.hpp

示例8: checkTrajectoriesForCollision

bool TrajectoryEvaluator::checkTrajectoriesForCollision(const std::multiset<PolyTraj2D, PolyTraj2D::CompPolyTraj2D>& traj_set,
    const std::map<int, Vehicle>& predicted_obstacles, const std::string set_name,
    std::multiset<PolyTraj2D>::const_iterator& best_traj, double& longest_time_to_collision) {

  bool collision = true, found_maybe = false;
  double collision_time;
  longest_time_to_collision = 0;
  std::multiset<PolyTraj2D>::const_iterator it_traj;
  uint32_t j = 0;
  for (it_traj = traj_set.begin(), j = 0; it_traj != traj_set.end(); it_traj++, j++) {

    TrjOccupancyState_t static_collision = TRJ_BLOCKED;
    if (obstacle_map_) {
      pthread_mutex_lock(&obstacle_map_mutex_);
      static_collision = checkCollisionStatic(it_traj->trajectory2D_); // TODO: add collision_time and longest_time_to_collision to static check
      pthread_mutex_unlock(&obstacle_map_mutex_);

      if (static_collision==TRJ_BLOCKED) {
        continue;
      }
//      std::vector<driving_common::TrajectoryPoint2D>::const_iterator tit = it_traj->trajectory2D_.begin(), tit_end = it_traj->trajectory2D_.end();
//      bool zero_velocity=true;
//      for(; tit!=tit_end; tit++) {
//      if(std::abs((*tit).v)>.01) {zero_velocity=false; break;}
//      }
//      if(zero_velocity) {continue;}
    }

    if (!checkCollisionOfTrajectoriesDynamic(it_traj->trajectory2D_, predicted_obstacles, collision_time)) {
      if (j != 0) {std::cout << j << "th trajectory (" << set_name << ") of " << traj_set.size() << " is free.\n";}
      longest_time_to_collision = std::numeric_limits<double>::infinity();
        // we found a collision-free trajectory regardless if it's in maybe range or not
      collision = false;
        // if we did not find any free before or we found a free now and had a maybe before => update best trajectory
      if(!found_maybe || static_collision==TRJ_FREE) {best_traj = it_traj;}
        // if there are only maybes we want the one that was found first since it's the best :-)
        // otherwise we found a free one and are done
      if(static_collision==TRJ_MAYBE_BLOCKED) {found_maybe=true;}
      else {
        break;
      }
    }
    else {
      if (collision_time > longest_time_to_collision) {
        longest_time_to_collision = collision_time;
        best_traj = it_traj;
      }
    }
  }

  return collision;
}
开发者ID:Forrest-Z,项目名称:stanford_self_driving_car_code,代码行数:52,代码来源:trajectoryEvaluator.cpp

示例9: total

double Basket::total() const
{
    double sum = 0.0;

    for(const_iter i = items.begin() ;  i != items.end() ; i = items.upper_bound(*i))
    {
        sum += (*i)->net_price(items.count(*i));
    }


    return sum;

}
开发者ID:QiJunHu,项目名称:learningRecord,代码行数:13,代码来源:learningHandleClass.cpp

示例10: judgeStatus

		virtual Json::Value judgeStatus()
		{
			Json::Value ret;
			ret["runningCnt"]=runningCnt;
			ret["totDumpCmdCnt"]=totCnt;
			ret["preserveCnt"]=preserveCnt;
			ret["boardingPass"]=Json::Value();
			pthread_mutex_lock(&cntLock);
			for (std::multiset<int>::iterator i=boardingPass.begin(); i!=boardingPass.end(); i++)
				ret["boardingPass"].append(*i);
			pthread_mutex_unlock(&cntLock);
			return ret;
		}
开发者ID:roastduck,项目名称:YAUJ,代码行数:13,代码来源:daemon.cpp

示例11: greater_than

inline bool greater_than(std::multiset< int > multiset1, std::multiset< int > multiset2){

			std::multiset< int >::iterator multiset1_itr = multiset1.begin(), multiset2_itr = multiset2.begin();
			int fi,fj;

 			for ( fi = multiset1.size(),fj = multiset2.size(); fi>0 && fj>0 ;fi--,fj--)
			{
 
				if (*multiset1_itr == *multiset2_itr)
				{
					multiset1_itr++ , multiset2_itr++;
				}
				else {
				
 					//return *multiset1_itr < *multiset2_itr ; //ascending
					return *multiset1_itr > *multiset2_itr ;//descending
				}
			}

			//Haven't returned yet and the foor loop exited, so that means the two input multiset have equal entries atleast the common portions 
 			//return (fi<fj);//asecending
			return (fi>fj);//descending
};
开发者ID:atripathy86,项目名称:srn,代码行数:23,代码来源:Node.hpp

示例12: unique

inline void converter<point_t>::knot_insertion(
    point_container_t& P,
    std::multiset<typename point_t::value_type>& knots,
    std::size_t order) const {
  //typedef typename point_t::value_type value_type;
  std::set<value_type> unique(knots.begin(), knots.end());

  for (typename std::set<value_type>::const_iterator i = unique.begin();
       i != unique.end();
       ++i) {
    if (knots.count(*i) < order - 1) {
      knot_insertion(P, knots, order, *i);
    }
  }
}
开发者ID:4og,项目名称:guacamole,代码行数:15,代码来源:converter_impl.hpp

示例13: RemoveNeighbours

void ExpMapGenerator::RemoveNeighbours( ExpMapParticle * pParticle, std::multiset< ParticleQueueWrapper > & pq )
{
	ExpMapParticle::ListEntry * pCur = GetNeighbourList( pParticle );
	if ( pCur == NULL ) lgBreakToDebugger();
	while ( pCur != NULL ) {

		ExpMapParticle * pCurParticle = pCur->pParticle;
		pCur = pCur->pNext;

		if ( pCurParticle->State() != ExpMapParticle::Active )
			continue;

		// find entry in pq
#if 1
		std::multiset<ParticleQueueWrapper>::iterator found( 
			pq.find( ParticleQueueWrapper( pCurParticle->SurfaceDistance() ) ) );
		if ( found != pq.end() ) {

			while ( (*found).Particle() != pCurParticle &&
						(*found).QueueValue() == pCurParticle->SurfaceDistance() )
				++found;

			// [RMS: this should always happen...]
			lgASSERT( (*found).Particle() == pCurParticle );
			if ( (*found).Particle() == pCurParticle ) {
				pq.erase( found );
			}
		} else {
			lgASSERT( found != pq.end() );
		}

#else 
		std::multiset<ParticleQueueWrapper>::iterator cur( pq.begin() );
		bool bFound = false;
		while ( !bFound && cur != pq.end() ) {
			if ( (*cur).Particle() == pCurParticle ) {
				pq.erase( cur );
				bFound = true;
			} else
				++cur;
		}
		lgASSERT( bFound );
#endif

	}
}
开发者ID:rms80,项目名称:libgeometry,代码行数:46,代码来源:ExpMapGenerator.cpp

示例14: operator

 void operator()(clmdep_msgpack::object::with_zone& o, const std::multiset<T, Compare, Alloc>& v) const {
     o.type = clmdep_msgpack::type::ARRAY;
     if (v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
         clmdep_msgpack::object* const pend = p + size;
         o.via.array.ptr = p;
         o.via.array.size = size;
         typename std::multiset<T, Compare, Alloc>::const_iterator it(v.begin());
         do {
             *p = clmdep_msgpack::object(*it, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
开发者ID:rpclib,项目名称:rpclib,代码行数:19,代码来源:set.hpp

示例15: f_multiset

void f_multiset() {
  std::multiset<int> C;
  std::multiset<int>::iterator MSetI1 = C.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto MSetI1 = C.begin();

  std::multiset<int>::reverse_iterator MSetI2 = C.rbegin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto MSetI2 = C.rbegin();

  const std::multiset<int> D;
  std::multiset<int>::const_iterator MSetI3 = D.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto MSetI3 = D.begin();

  std::multiset<int>::const_reverse_iterator MSetI4 = D.rbegin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto MSetI4 = D.rbegin();
}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:19,代码来源:modernize-use-auto-iterator.cpp


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