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


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

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


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

示例1: CeresDiffInnerProductVectorVector

py::list CeresDiffInnerProductVectorVector(const Vec &vec, const Vec &vec2) {
  auto py_array_jac = py::array(py::buffer_info(
      nullptr, sizeof(double), py::format_descriptor<double>::value(), 2,
      {1, 3}, {sizeof(double) * 3, sizeof(double)}));

  auto py_array_result = py::array(py::buffer_info(
      nullptr, sizeof(double), py::format_descriptor<double>::value(), 2,
      {1, 1}, {sizeof(double), sizeof(double)}));

  auto buf_jac = py_array_jac.request();
  auto buf_res = py_array_result.request();

  const double *parameters[2] = {vec.begin(), vec2.begin()};
  double *jacobians[2] = {static_cast<double *>(buf_jac.ptr), nullptr};

  ceres::AutoDiffCostFunction<InnerProductVectorVectorFunctor, 1, 3, 3>(
      new InnerProductVectorVectorFunctor())
      .Evaluate(parameters, static_cast<double *>(buf_res.ptr), jacobians);

  py::list list;
  list.append(py_array_result);
  list.append(py_array_jac);

  return list;
}
开发者ID:tingelst,项目名称:game,代码行数:25,代码来源:autodiff_multivector.cpp

示例2: get

 uint32_t get(uint32_t pos) const
 {
     assert(!v_.empty() && v_[0] == 0);
     Vec::const_iterator i = std::lower_bound(v_.begin(), v_.end(), pos + 1);
     if (i == v_.end()) return (uint32_t)v_.size() - 1;
     return (uint32_t)std::distance(v_.begin(), i) - 1;
 }
开发者ID:herumi,项目名称:misc,代码行数:7,代码来源:ascendvec.cpp

示例3: main

int main(){
	int cases=0;
	while(1){
		int n,q;
		cin>>n>>q;
		if(n==0) break;
		++cases;
		cout<<"CASE# "<<cases<<":"<<endl;
		marble.clear();
		int k;
		for(int i=0;i<n;++i) {cin>>k;marble.push_back(k);}
		sort(marble.begin(),marble.end());
		for(int i=0;i<q;i++){
			cin>>k;
			Vec::iterator it=lower_bound(marble.begin(),marble.end(), k);
			if(it!=marble.end() && *it==k){
				cout<<k<<" found at "<<it-marble.begin()+1<<endl;
			}else{
				cout<<k<<" not found"<<endl;

			}
		}
	}
	return 0;	
}
开发者ID:liuhb86,项目名称:uva,代码行数:25,代码来源:10474.cpp

示例4: main

int main(){
	int kase =0;
	while(true){
		int c,s,q;
		cin>>c>>s>>q;
		if (c==0) break;
		++kase;
		edges.clear();
		for(int i=0;i<s;++i){
			Edge e;
			cin>>e.from>>e.to>>e.weight;
			edges.push_back(e);
		}
		sort(edges.begin(), edges.end());
		for(int i=1;i<=c;++i){
			nodes[i].parent = nodes+i;
			nodes[i].count = 0;
			nodes[i].edges.clear();
		}
		int count =0;
		for(Vec::iterator it = edges.begin(); count< c-1 && it!= edges.end(); ++it){
			Node *rs = getRoot(it->from), *rt = getRoot(it->to);
			if(rs == rt) continue;
			if (rs->count > rt->count){
				rt->parent = rs;
				rs->count+=rt->count;
			} else {
				rs->parent = rt;
				rt->count += rs->count;
			}
			++count;

			nodes[it->from].edges.push_back(*it);
			int tmp = it->to;
			it->to = it->from; it->from =tmp;
			nodes[it->from].edges.push_back(*it);
		}
		if (kase >1) cout<<endl;
		cout<<"Case #"<<kase<<endl;
		for(int i=0;i<q; ++i){
			int s,t;
			cin>>s>>t;
			CalcResult result = calc(s,t,0);
			if (result.reached) {
				cout<<result.value<<endl;
			} else {
				cout<<"no path"<<endl;
			}
		}
	}
	return 0;
}
开发者ID:liuhb86,项目名称:uva,代码行数:52,代码来源:10048.cpp

示例5: init

 void init(const Vec &from, VecTo &to)
 {
   base=&*from.begin();
   to.clear();
   for (unsigned i = 0, e = from.size(); i<e; ++i)
     to.push_back(i);
 }
开发者ID:SlyryD,项目名称:carmel,代码行数:7,代码来源:indirect.hpp

示例6: initDiffApplication

 void
 initDiffApplication()
 {
     swap (seq_, orig_);
     seq_.reserve (orig_.size() * 120 / 100);    // heuristics for storage pre-allocation
     pos_ = orig_.begin();
 }
开发者ID:Ichthyostega,项目名称:Lumiera,代码行数:7,代码来源:list-diff-application.hpp

示例7: CeresDiffRotorGaalop

py::list CeresDiffRotorGaalop(const double theta, const Vec &a) {
  auto py_array_jac = py::array(py::buffer_info(
      nullptr, sizeof(double), py::format_descriptor<double>::value(), 2,
      {3, 1}, {sizeof(double), sizeof(double)}));

  auto py_array_result = py::array(py::buffer_info(
      nullptr, sizeof(double), py::format_descriptor<double>::value(), 2,
      {3, 1}, {sizeof(double), sizeof(double)}));

  auto buf_jac = py_array_jac.request();
  auto buf_res = py_array_result.request();

  const double *parameters[2] = {&theta, a.begin()};
  double *jacobians[2] = {static_cast<double *>(buf_jac.ptr), nullptr};

  ceres::AutoDiffCostFunction<DiffRotorGaalopFunctor, 3, 1, 3>(
      new DiffRotorGaalopFunctor())
      .Evaluate(parameters, static_cast<double *>(buf_res.ptr), jacobians);

  py::list list;
  list.append(py_array_result);
  list.append(py_array_jac);

  return list;
}
开发者ID:tingelst,项目名称:game,代码行数:25,代码来源:autodiff_multivector.cpp

示例8: print

 static void print(const Vec& u)
 {
   Vec::const_iterator it = u.begin();
   for(;it != u.end(); it ++) {
     printf("v[%d] = %lf\n", it->first, it->second);
   }
 }
开发者ID:yesyestian,项目名称:BNB-solver,代码行数:7,代码来源:rna.hpp

示例9: main

int main(int argc, const char *argv[])
{
    Vec<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (record.read(cin)) {
        maxlen = max(maxlen, record.name().size());
        students.push_back(record);
    }

    //  
    sort(students.begin(), students.end(), compare);

    for (Vec<double>::size_type i = 0; i != students.size(); i++) {
        cout << students[i].name() << string(maxlen + 1 - students[i].name().size(), ' ');
        try {
            double final_grade = students[i].grade();
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade << setprecision(prec) << endl;
        } catch (domain_error e) {
            cout << e.what() << endl;
        }
    }
    return 0;
}
开发者ID:chibby0ne,项目名称:AcceleratedC,代码行数:26,代码来源:exercise7.cpp

示例10:

TEST(CollectionUtilsTest, vecShiftLeftByMoreThanSize) {
    typedef std::vector<size_t> Vec;
    Vec vec;
    
    vec.push_back('a');
    vec.push_back('b');
    vec.push_back('c');
    vec.push_back('d');
    vec.push_back('e');
    vec.push_back('f');
    vec.push_back('g');
    
    Vec leftBy10;
    leftBy10.push_back('d');
    leftBy10.push_back('e');
    leftBy10.push_back('f');
    leftBy10.push_back('g');
    leftBy10.push_back('a');
    leftBy10.push_back('b');
    leftBy10.push_back('c');

    Vec actual = vec;
    VectorUtils::shiftLeft(actual, 10);
    ASSERT_TRUE(std::equal(leftBy10.begin(), leftBy10.end(), actual.begin()));
}
开发者ID:kduske,项目名称:Tippi,代码行数:25,代码来源:CollectionUtilsTest.cpp

示例11: apply1_wores_vec

void apply1_wores_vec (Vec& a, UFunc f)
{
    if(a.is_empty())
        return;
    typedef typename cnc_iterator<Vec>::type Iter;
    for(Iter i = a.begin(), iend = a.end(); i != iend; ++i)
        f(*i);
}
开发者ID:sig-vip,项目名称:skeleton,代码行数:8,代码来源:vecalg.hpp

示例12: unvectorize

 void unvectorize(std::vector<Ptr<Sufstat> >  &svec,
                  const Vec &v,
                  bool minimal){
   Vec::const_iterator it=v.begin();
   for(uint i=0; i<svec.size(); ++i){
     it = svec[i]->unvectorize(it, minimal);
   }
 }
开发者ID:comenerv,项目名称:Boom,代码行数:8,代码来源:Sufstat.cpp

示例13: ImmediateB

   void ImmediateB (const Vec& s){
     //cout << "ehl" << endl;
     gfx::Glyph::Line(s);
     glPushMatrix();  
     gfx::GL::translate( s.begin() );
     gfx::Glyph::SolidSphere(.05,5,5);
     glPopMatrix();                       
 }
开发者ID:mapleyustat,项目名称:versor,代码行数:8,代码来源:vsr_cga3D_draw.cpp

示例14: average_analysis

double average_analysis(const Vec<Student_info>& students)
{
    Vec<double> grades;

    transform(students.begin(), students.end(),
              back_inserter(grades), average_grade);
    return median(grades);
}
开发者ID:estiljr,项目名称:C--Intro,代码行数:8,代码来源:analysis.cpp

示例15: assert

      ~GeneratedCode() {
         /*
          * Deallocate things as previously requested and
          * free shared manager when no longer used.
          */
#if HAVE_LLVM < 0x0306
         Vec::iterator i;

         assert(TheMM);
         for ( i = FunctionBody.begin(); i != FunctionBody.end(); ++i )
            TheMM->deallocateFunctionBody(*i);
#if HAVE_LLVM < 0x0304
         for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i )
            TheMM->deallocateExceptionTable(*i);
#endif /* HAVE_LLVM < 0x0304 */
#endif /* HAVE_LLVM < 0x0306 */
      }
开发者ID:chemecse,项目名称:mesa,代码行数:17,代码来源:lp_bld_misc.cpp


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