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


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

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


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

示例1: if

bool OBJCTXT<_DOF6>::merge(const OBJCTXT &ctxt, const DOF6 &tf, std::map<typename OBJECT::Ptr,bool> &used_out, const BoundingBox::TransformedFoVBB &fov, const bool only_merge)
{
  Debug::Interface::get().sayTook("merge start");
  ROS_INFO("nextPoint ctr %d", (int)Slam_Surface::___CTR___);

  ++frames_;

  const size_t old = objs_.size();
  const float uncertainity = 0.01f;

  if(old>0 && (tf.getTranslationVariance()+tf.getRotationVariance())>0.3f )// && (tf.getSource1()->getTranslationVariance()+tf.getSource1()->getRotationVariance())>0.3 )
    return false;

  ROS_INFO("add ctxt %d", (int)used_out.size());
  std::cout<<tf<<"\n";

  Eigen::Vector3f edges[8];
  for(size_t i=0; i<objs_.size(); i++)
  {
    bool in=fov&objs_[i]->getNearestPoint();
    if(!in) {
      objs_[i]->getBB().get8Edges(edges);
      for(size_t i=0; i<8; i++)
        if(fov&edges[i]) {in=true; break;}
    }

    if(objs_[i]->getBB().extension()>2.5f)
      in=false;

    if( in ) {
#ifdef DEBUG_OUTPUT_
      ROS_INFO("FoV: in");
#endif
      objs_[i]->processed(); //TODO: check FoV
    }
    else {
#ifdef DEBUG_OUTPUT_
      ROS_INFO("FoV: out");
#endif
      objs_[i]->notProcessed(); //TODO: check FoV
    }
  }

  Debug::Interface::get().sayTook("merge 1");
  ROS_INFO("nextPoint ctr %d", (int)Slam_Surface::___CTR___);

  std::map<typename OBJECT::Ptr,std::vector<typename OBJECT::Ptr> > used;

  DOF6 tmp_link = tf.transpose();

  for(typename std::vector<SCOR>::const_iterator it = used_cors_.begin(); it!=used_cors_.end(); it++)
  {
    if(!it->a || !it->b || !it->used_) continue;

    //used_out[it->b] = true;

    typename OBJECT::Ptr o=it->b->makeShared();
    o->transform(tmp_link.getRotation(), tmp_link.getTranslation(),
                 tf.getRotationVariance()+uncertainity, tf.getTranslationVariance()+uncertainity);

    it->a->used();

    if(((*it->a) += *o)
    )
    {
      used_out[it->b] = true;

      used[it->b].push_back(it->a);
      ROS_INFO("update object");
    }
    else {
      //it->a->used();
      ROS_INFO("NOT update object");
    }
  }

  Debug::Interface::get().sayTook("merge 2");
  ROS_INFO("nextPoint ctr %d", (int)Slam_Surface::___CTR___);

  for(size_t i=0; i<ctxt.objs_.size(); i++)
  {
    typename std::map<typename OBJECT::Ptr,std::vector<typename OBJECT::Ptr> >::const_iterator it = used.find(ctxt.objs_[i]);

    if(used.end() == it)
    {
      if(used_out.find(ctxt.objs_[i])!=used_out.end())
        continue;

      if(!only_merge || (bb_.transform(tf.getRotation(), tf.getTranslation())&ctxt.objs_[i]->getNearestPoint()) ) //add to "first"/actual node or if its contained in this node
      {

        typename OBJECT::Ptr o=ctxt.objs_[i]->makeShared();
        o->transform(((Eigen::Matrix3f)tmp_link.getRotation()),tmp_link.getTranslation(),
                     tmp_link.getRotationVariance()+uncertainity, tmp_link.getTranslationVariance()+uncertainity);

        bool found = false;
        for(size_t j=0; j<objs_.size(); j++)
        {
          if( (objs_[j]->getBB()&(o->getBB()//.changeSize(0.8f)
          )) &&
//.........这里部分代码省略.........
开发者ID:Etimr,项目名称:cob_environment_perception,代码行数:101,代码来源:objctxt.hpp

示例2: if

void
AmclNode::laserReceived(const sensor_msgs::LaserScanConstPtr& laser_scan)
{
  last_laser_received_ts_ = ros::Time::now();
  if( map_ == NULL ) {
    return;
  }
  boost::recursive_mutex::scoped_lock lr(configuration_mutex_);
  int laser_index = -1;

  // Do we have the base->base_laser Tx yet?
  if(frame_to_laser_.find(laser_scan->header.frame_id) == frame_to_laser_.end())
  {
    ROS_DEBUG("Setting up laser %d (frame_id=%s)\n", (int)frame_to_laser_.size(), laser_scan->header.frame_id.c_str());
    lasers_.push_back(new AMCLLaser(*laser_));
    lasers_update_.push_back(true);
    laser_index = frame_to_laser_.size();

    tf::Stamped<tf::Pose> ident (tf::Transform(tf::createIdentityQuaternion(),
                                             tf::Vector3(0,0,0)),
                                 ros::Time(), laser_scan->header.frame_id);
    tf::Stamped<tf::Pose> laser_pose;
    try
    {
      this->tf_->transformPose(base_frame_id_, ident, laser_pose);
    }
    catch(tf::TransformException& e)
    {
      ROS_ERROR("Couldn't transform from %s to %s, "
                "even though the message notifier is in use",
                laser_scan->header.frame_id.c_str(),
                base_frame_id_.c_str());
      return;
    }

    pf_vector_t laser_pose_v;
    laser_pose_v.v[0] = laser_pose.getOrigin().x();
    laser_pose_v.v[1] = laser_pose.getOrigin().y();
    // laser mounting angle gets computed later -> set to 0 here!
    laser_pose_v.v[2] = 0;
    lasers_[laser_index]->SetLaserPose(laser_pose_v);
    ROS_DEBUG("Received laser's pose wrt robot: %.3f %.3f %.3f",
              laser_pose_v.v[0],
              laser_pose_v.v[1],
              laser_pose_v.v[2]);

    frame_to_laser_[laser_scan->header.frame_id] = laser_index;
  } else {
    // we have the laser pose, retrieve laser index
    laser_index = frame_to_laser_[laser_scan->header.frame_id];
  }

  // Where was the robot when this scan was taken?
  pf_vector_t pose;
  if(!getOdomPose(latest_odom_pose_, pose.v[0], pose.v[1], pose.v[2],
                  laser_scan->header.stamp, base_frame_id_))
  {
    ROS_ERROR("Couldn't determine robot's pose associated with laser scan");
    return;
  }


  pf_vector_t delta = pf_vector_zero();

  if(pf_init_)
  {
    // Compute change in pose
    //delta = pf_vector_coord_sub(pose, pf_odom_pose_);
    delta.v[0] = pose.v[0] - pf_odom_pose_.v[0];
    delta.v[1] = pose.v[1] - pf_odom_pose_.v[1];
    delta.v[2] = angle_diff(pose.v[2], pf_odom_pose_.v[2]);

    // See if we should update the filter
    bool update = fabs(delta.v[0]) > d_thresh_ ||
                  fabs(delta.v[1]) > d_thresh_ ||
                  fabs(delta.v[2]) > a_thresh_;
    update = update || m_force_update;
    m_force_update=false;

    // Set the laser update flags
    if(update)
      for(unsigned int i=0; i < lasers_update_.size(); i++)
        lasers_update_[i] = true;
  }

  bool force_publication = false;
  if(!pf_init_)
  {
    // Pose at last filter update
    pf_odom_pose_ = pose;

    // Filter is now initialized
    pf_init_ = true;

    // Should update sensor data
    for(unsigned int i=0; i < lasers_update_.size(); i++)
      lasers_update_[i] = true;

    force_publication = true;

//.........这里部分代码省略.........
开发者ID:Benson516,项目名称:navigation_old_kinetic,代码行数:101,代码来源:amcl_node.cpp

示例3: adjustBundle

void BundleAdjuster::adjustBundle(vector<CloudPoint>& pointcloud, 
								  Mat& cam_matrix,
								  const std::vector<std::vector<cv::KeyPoint> >& imgpts,
								  std::map<int ,cv::Matx34d>& Pmats
								) 
{
	int N = Pmats.size(), M = pointcloud.size(), K = Count2DMeasurements(pointcloud);
	
	cout << "N (cams) = " << N << " M (points) = " << M << " K (measurements) = " << K << endl;
	
#ifdef HAVE_SSBA
	/********************************************************************************/
	/*	Use SSBA-3.0 for sparse bundle adjustment									*/
	/********************************************************************************/
	
	
	StdDistortionFunction distortion;
	
	//conver camera intrinsics to BA datastructs
	Matrix3x3d KMat;
	makeIdentityMatrix(KMat);
	KMat[0][0] = cam_matrix.at<double>(0,0); //fx
	KMat[1][1] = cam_matrix.at<double>(1,1); //fy
	KMat[0][1] = cam_matrix.at<double>(0,1); //skew
	KMat[0][2] = cam_matrix.at<double>(0,2); //ppx
	KMat[1][2] = cam_matrix.at<double>(1,2); //ppy
	
	double const f0 = KMat[0][0];
	cout << "intrinsic before bundle = "; displayMatrix(KMat);
	Matrix3x3d Knorm = KMat;
	// Normalize the intrinsic to have unit focal length.
	scaleMatrixIP(1.0/f0, Knorm);
	Knorm[2][2] = 1.0;
	
	vector<int> pointIdFwdMap(M);
	map<int, int> pointIdBwdMap;
	
	//conver 3D point cloud to BA datastructs
	vector<Vector3d > Xs(M);
	for (int j = 0; j < M; ++j)
	{
		int pointId = j;
		Xs[j][0] = pointcloud[j].pt.x;
		Xs[j][1] = pointcloud[j].pt.y;
		Xs[j][2] = pointcloud[j].pt.z;
		pointIdFwdMap[j] = pointId;
		pointIdBwdMap.insert(make_pair(pointId, j));
	}
	cout << "Read the 3D points." << endl;
	
	vector<int> camIdFwdMap(N,-1);
	map<int, int> camIdBwdMap;
	
	//convert cameras to BA datastructs
	vector<CameraMatrix> cams(N);
	for (int i = 0; i < N; ++i)
	{
		int camId = i;
		Matrix3x3d R;
		Vector3d T;
		
		Matx34d& P = Pmats[i];
		
		R[0][0] = P(0,0); R[0][1] = P(0,1); R[0][2] = P(0,2); T[0] = P(0,3);
		R[1][0] = P(1,0); R[1][1] = P(1,1); R[1][2] = P(1,2); T[1] = P(1,3);
		R[2][0] = P(2,0); R[2][1] = P(2,1); R[2][2] = P(2,2); T[2] = P(2,3);
		
		camIdFwdMap[i] = camId;
		camIdBwdMap.insert(make_pair(camId, i));
		
		cams[i].setIntrinsic(Knorm);
		cams[i].setRotation(R);
		cams[i].setTranslation(T);
	}
	cout << "Read the cameras." << endl;
	
	vector<Vector2d > measurements;
	vector<int> correspondingView;
	vector<int> correspondingPoint;
	
	measurements.reserve(K);
	correspondingView.reserve(K);
	correspondingPoint.reserve(K);
	
	//convert 2D measurements to BA datastructs
	for (unsigned int k = 0; k < pointcloud.size(); ++k)
	{
		for (unsigned int i=0; i<pointcloud[k].imgpt_for_img.size(); i++) {
			if (pointcloud[k].imgpt_for_img[i] >= 0) {
				int view = i, point = k;
				Vector3d p, np;
				
				Point cvp = imgpts[i][pointcloud[k].imgpt_for_img[i]].pt;
				p[0] = cvp.x;
				p[1] = cvp.y;
				p[2] = 1.0;
				
				if (camIdBwdMap.find(view) != camIdBwdMap.end() &&
					pointIdBwdMap.find(point) != pointIdBwdMap.end())
				{
//.........这里部分代码省略.........
开发者ID:AshwinRajendraprasad,项目名称:SfM-Toy-Library,代码行数:101,代码来源:BundleAdjuster.cpp

示例4: Write

void BinaryWriter::Write(std::string fname,
  std::map<std::string, std::string> parameters,
  double *positions,
  std::vector<IntField*> intFields,
  std::vector<DoubleField*> doubleFields,
  int dim,
  long numParticles
  )
{
  std::map<std::string, std::string>::iterator it;
  int progress = 1;
  int j = 0;
  int k = 0;
  double temp;

  if(numParticles == 0)
  {
    std::cout << "Error: Number of particles is 0, exiting" << std::endl;
    std::exit(1);
  }

  ProgressBar pb(intFields.size()+doubleFields.size()+parameters.size()+1,"Writing output");

  std::ofstream outfile((char*)fname.c_str(), std::ios::binary);
  if(outfile.is_open()) 
  {
    std::cout << "Writing to output file..." << std::flush;

    outfile <<  "# vtk DataFile Version 1.0" << std::endl;
    outfile <<  "vtk output" << std::endl;
    outfile <<  "BINARY" << std::endl;
    outfile <<  "DATASET POLYDATA" << std::endl;
    outfile <<  "POINTS " << numParticles << " double" << std::endl;
   for ( int i = 0; i<numParticles; i++ ) // All positions, duplicate this loop to write extra arrays
   {
    j = 3*i;

    // SwapEnd(positions[j]);
    // outfile.write((char*)&positions[j], sizeof(double));
    // SwapEnd(positions[j+1]);
    // outfile.write((char*)&positions[j+1], sizeof(double));
    // SwapEnd(positions[j+2]);
    // outfile.write((char*)&positions[j+2], sizeof(double));

    temp = std::stod(std::to_string(positions[j]));
    SwapEnd(temp);
    outfile.write((char*)&temp, sizeof(double));
    temp = std::stod(std::to_string(positions[j+1]));
    SwapEnd(temp);
    outfile.write((char*)&temp, sizeof(double));
    temp = std::stod(std::to_string(positions[j+2]));
    SwapEnd(temp);
    outfile.write((char*)&temp, sizeof(double));

   }	

    outfile <<  std::endl; // NEW LINE

    outfile <<  "POINT_DATA " << numParticles << std::endl;

    outfile <<  "FIELD FieldData " << doubleFields.size()+intFields.size() << std::endl;

    for (long intf=0; intf < intFields.size(); intf++)
    {
      IntField *thisField = intFields[intf];

      outfile <<  thisField->name << " " << thisField->dim << " " << numParticles << " integer" << std::endl;

      for ( int i = 0; i<numParticles; i++ )
      {

        k= thisField->dim * i;

        for( int l=0; l<thisField->dim; l++)
        {

          SwapEnd(thisField->data[k+l]);
          outfile.write((char*)&thisField->data[k+l], sizeof(int));


        }
      }

      outfile <<  std::endl;
    }

    for (long intf=0; intf < doubleFields.size(); intf++)
    {
      DoubleField *thisField = doubleFields[intf];

      outfile <<  thisField->name << " " << thisField->dim << " " << numParticles << " double" << std::endl;

      for ( int i = 0; i<numParticles; i++ )
      {
        k= thisField->dim * i;
        for( int l=0; l<thisField->dim; l++)
        {

          SwapEnd(thisField->data[k+l]);
          outfile.write((char*)&thisField->data[k+l], sizeof(double));
//.........这里部分代码省略.........
开发者ID:brucedjones,项目名称:pyck,代码行数:101,代码来源:binaryWriter.cpp

示例5: getProbsMorphs

void getProbsMorphs(std::map< int, std::map< int, std::string > >& sentMatrix, const lm::ngram::Model &model){

	std::vector<std::pair<float, int> > sortedOpts;

	for(int opt=0; opt<sentMatrix.size();opt++){
			//std::cerr << opt << ": ";
			std::map< int, std::string> sent = sentMatrix[opt];

			lm::ngram::State state(model.BeginSentenceState()), out_state;
			// no sentence context
			//lm::ngram::State state(model.NullContextState()), out_state;
			const lm::ngram::Vocabulary &vocab = model.GetVocabulary();


			lm::FullScoreReturn ret;
			float total =0.0;

			for(int i=0;i<sent.size();i++)
			{
				std::string w = sent[i];
				//std::cerr << "word : "<< w << "sent size: "<< sent.size() << "\n";
				// alternatives start with '/' and punctuation end with -PUNC-tag -> delete tag and leading '/'
				if(boost::starts_with(w,"/")){boost::erase_head(w,1);}

				if(boost::contains(w,"-PUNC-")){w = w.substr(0,1);}

				// proper names are marked with _NP -> use only NP for getting probs
				std::string newLem = "NP:";
				boost::regex re("^.+_NP:");
				if(boost::contains(w,"_NP:")){
					w  = boost::regex_replace(w, re, newLem);
				}

				// split word into morphs and get probabilities
				std::vector<std::string> strs;
				boost::split(strs,w,boost::is_any_of(":"));
				std::string lem = strs[0];
				std::vector<std::string> morphs;
				boost::regex morphrx("\\+[^\\+]+");
				if(strs.size() > 1){
					boost::find_all_regex(morphs, strs[1], morphrx);
				}

				//std::cerr << "lemma: " << lem << ", morph size " << morphs.size() <<"\n";
				/*for(int j=0;j<morphs.size();j++){
					std::cerr << "    morph: " << morphs[j] << "\n";
				}*/

				ret = model.FullScore(state, vocab.Index(lem), out_state);
				//std::cerr << "tested word " << w << " ,full p: " << ret.prob << " == " <<vocab.Index(w) << "\n";
				total += ret.prob;
				state = out_state;
				// get Probs for morphs
				for(int j=0;j<morphs.size();j++){
					ret = model.FullScore(state, vocab.Index(morphs[j]), out_state);
					total += ret.prob;
					//std::cerr << "tested morph " <<  morphs[j] << " ,p: " << ret.prob << " == " <<vocab.Index(morphs[j]) << "\n";
					state = out_state;
				}

			}
			ret = model.FullScore(state, model.GetVocabulary().EndSentence(), out_state);
			total += ret.prob;
			//std::cerr  <<  " total p: " << total <<'\n';
			std::pair<float,int> mypair (total, opt);
			sortedOpts.push_back(mypair);
		}
	 if(print_test_morph ==1){
		// std::cerr << "printing test morphs" << std::endl;
		 printTestMorphs(sentMatrix,sortedOpts);
	 }
	 else{
		 printSentsMorphGen(sentMatrix,sortedOpts);
		// std::cerr << "printing generated words" << std::endl;
	//std::cerr << "\n";
	 }
}
开发者ID:hinantin,项目名称:squoia,代码行数:77,代码来源:outputSentences.cpp

示例6: RunBefore

void Input::RunBefore() {

    if (inputLocked) return;
    lockCallbackMaps = true;

    for(int i = 0; i < thisState.numDevices; ++i) {
        if (thisState.devices[i])
            thisState.devices[i]->CopyInto(prevState.devices[i]); //TODO
    }


    // Set the focus to the display that has input focus (which
    // isnt necessarily the main display);
    std::vector<ViewID> dpys = ViewManager::ListViews();
    Display * focus = nullptr;
    for(uint32_t i = 0; i < dpys.size(); ++i) {
        focus = ViewManager::Get(dpys[i]);
        if (focus && focus->HasInputFocus()) {
            focusID = dpys[i];
            break;
        }
        focusID = ViewID();
        focus = nullptr;
    }
    manager->SetFocus(focus);


    bool updated = manager->HandleEvents();
    
    if (keyCallbackMap.size()) {
        for(auto i = keyCallbackMap.begin(); i != keyCallbackMap.end(); ++i) {
            if (Input::IsPressed(i->second))
                i->first->OnPress();
            if (Input::IsHeld(i->second))
                i->first->OnHold();
            if (Input::IsReleased(i->second))
                i->first->OnRelease();
        }
    }

    if (mouseCallbackMap.size()) {
        for(auto i = mouseCallbackMap.begin(); i != mouseCallbackMap.end(); ++i) {
            if (Input::IsPressed(i->second))
                i->first->OnPress();
            if (Input::IsHeld(i->second))
                i->first->OnHold();
            if (Input::IsReleased(i->second))
                i->first->OnRelease();
        }
    }
    
    /*
    // TODO: for pad support
    if (padCallbackMap.size()) {
        for(auto i = padCallbackMap.begin(); i != padCallbackMap.end(); ++i) {
            if (Input::IsPressed(i->second.first, i->second.second))
                i->first->OnPress();
            if (Input::IsHeld(i->second.first, i->second.second))
                i->first->OnHold();
            if (Input::IsReleased(i->second.first, i->second.second))
                i->first->OnRelease();
        }
    }
    */

    if (strCallbackMap.size()) {
        for(auto i = strCallbackMap.begin(); i != strCallbackMap.end(); ++i) {
            if (Input::IsPressed(i->second))
                i->first->OnPress();
            if (Input::IsHeld(i->second))
                i->first->OnHold();
            if (Input::IsReleased(i->second))
                i->first->OnRelease();
        }
    }
    lockCallbackMaps = false;
    for(uint32_t i = 0; i < deletedListeners.size(); ++i) {
        auto b = deletedListeners[i];
        auto pFind = padCallbackMap.find(b);
        if (pFind != padCallbackMap.end()) padCallbackMap.erase(pFind);

        auto mFind = mouseCallbackMap.find(b);
        if (mFind != mouseCallbackMap.end()) mouseCallbackMap.erase(mFind);

        auto kFind = keyCallbackMap.find(b);
        if (kFind != keyCallbackMap.end()) keyCallbackMap.erase(kFind);

        auto sFind = strCallbackMap.find(b);
        if (sFind != strCallbackMap.end()) strCallbackMap.erase(sFind);
    }
    deletedListeners.clear();

    if (updated) {
        getUnicode();
    }
}
开发者ID:jcorks,项目名称:Dynacoe,代码行数:96,代码来源:Input.cpp

示例7: operator

 size_t operator()(const std::map<CborValue, CborValue> &map) const
 {
     return map.size();
 }
开发者ID:nekipelov,项目名称:cborcpp,代码行数:4,代码来源:cborvalue.cpp

示例8: construct_compose

void AbsDef::construct_compose( FirstOrderModelAbs * m, TNode q, TNode n, AbsDef * f,
                                std::map< unsigned, AbsDef * >& children,
                                std::map< unsigned, int >& bchildren, std::map< unsigned, int >& vchildren,
                                std::vector< unsigned >& entry, std::vector< bool >& entry_def ) {
  if( n.getKind()==OR || n.getKind()==AND ){
    // short circuiting
    for( std::map< unsigned, AbsDef * >::iterator it = children.begin(); it != children.end(); ++it ){
      if( ( it->second->d_value==0 && n.getKind()==AND ) ||
          ( it->second->d_value==1 && n.getKind()==OR ) ){
        //std::cout << "Short circuit " << it->second->d_value << " " << entry.size() << "/" << q[0].getNumChildren() << std::endl;
        unsigned count = q[0].getNumChildren() - entry.size();
        for( unsigned i=0; i<count; i++ ){
          entry.push_back( m->d_domain[m->getVariable( q, entry.size() ).getType()] );
          entry_def.push_back( true );
        }
        construct_entry( entry, entry_def, it->second->d_value );
        for( unsigned i=0; i<count; i++ ){
          entry.pop_back();
          entry_def.pop_back();
        }
        return;
      }
    }
  }
  if( entry.size()==q[0].getNumChildren() ){
    if( f ){
      if( Trace.isOn("ambqi-check-debug2") ){
        for( unsigned i=0; i<entry.size(); i++ ){ Trace("ambqi-check-debug2") << "  "; }
        Trace("ambqi-check-debug2") << "Evaluate uninterpreted function entry..." << std::endl;
      }
      //we are composing with an uninterpreted function
      std::vector< int > values;
      values.resize( n.getNumChildren(), val_none );
      for( std::map< unsigned, AbsDef * >::iterator it = children.begin(); it != children.end(); ++it ){
        values[it->first] = it->second->d_value;
      }
      for( std::map< unsigned, int >::iterator it = bchildren.begin(); it != bchildren.end(); ++it ){
        values[it->first] = it->second;
      }
      //look up value(s)
      f->apply_ucompose( m, q, entry, entry_def, values, vchildren, this );
    }else{
      bool incomplete = false;
      //we are composing with an interpreted function
      std::vector< TNode > values;
      values.resize( n.getNumChildren(), TNode::null() );
      for( std::map< unsigned, AbsDef * >::iterator it = children.begin(); it != children.end(); ++it ){
        Trace("ambqi-check-debug2") << "composite : " << it->first << " : " << it->second->d_value;
        if( it->second->d_value>=0 ){
          if( it->second->d_value>=(int)m->d_rep_set.d_type_reps[n[it->first].getType()].size() ){
            std::cout << it->second->d_value << " " << n[it->first] << " " << n[it->first].getType() << " " << m->d_rep_set.d_type_reps[n[it->first].getType()].size() << std::endl;
          }
          Assert( it->second->d_value<(int)m->d_rep_set.d_type_reps[n[it->first].getType()].size() );
          values[it->first] = m->d_rep_set.d_type_reps[n[it->first].getType()][it->second->d_value];
        }else{
          incomplete = true;
        }
        Trace("ambqi-check-debug2") << " ->> " << values[it->first] << std::endl;
      }
      for( std::map< unsigned, int >::iterator it = bchildren.begin(); it != bchildren.end(); ++it ){
        Trace("ambqi-check-debug2") << "   basic :  " << it->first << " : " << it->second;
        if( it->second>=0 ){
          Assert( it->second<(int)m->d_rep_set.d_type_reps[n[it->first].getType()].size() );
          values[it->first] = m->d_rep_set.d_type_reps[n[it->first].getType()][it->second];
        }else{
          incomplete = true;
        }
        Trace("ambqi-check-debug2") << " ->> " << values[it->first] << std::endl;
      }
      Assert( vchildren.empty() );
      if( incomplete ){
        Trace("ambqi-check-debug2") << "Construct incomplete entry." << std::endl;

        //if a child is unknown, we must return unknown
        construct_entry( entry, entry_def, val_unk );
      }else{
        if( Trace.isOn("ambqi-check-debug2") ){
          for( unsigned i=0; i<entry.size(); i++ ){ Trace("ambqi-check-debug2") << "  "; }
          Trace("ambqi-check-debug2") << "Evaluate interpreted function entry ( ";
          for( unsigned i=0; i<values.size(); i++ ){
            Assert( !values[i].isNull() );
            Trace("ambqi-check-debug2") << values[i] << " ";
          }
          Trace("ambqi-check-debug2") << ")..." << std::endl;
        }
        //evaluate
        Node vv = NodeManager::currentNM()->mkNode( n.getKind(), values );
        vv = Rewriter::rewrite( vv );
        int v = m->getRepresentativeId( vv );
        construct_entry( entry, entry_def, v );
      }
    }
  }else{
    //take product of arguments
    TypeNode tn = m->getVariable( q, entry.size() ).getType();
    Assert( m->isValidType( tn ) );
    unsigned def = m->d_domain[tn];
    if( Trace.isOn("ambqi-check-debug2") ){
      for( unsigned i=0; i<entry.size(); i++ ){ Trace("ambqi-check-debug2") << "  "; }
      Trace("ambqi-check-debug2") << "Take product of arguments" << std::endl;
//.........这里部分代码省略.........
开发者ID:jinala,项目名称:CVC4,代码行数:101,代码来源:ambqi_builder.cpp

示例9: Rename

void CDeskBand::Rename(HWND hwnd, const std::map<std::wstring, ULONG>& items)
{
    // fill the list of selected file/foldernames
    m_filelist.clear();
    if (items.size() > 1)
    {
        for (std::map<std::wstring, ULONG>::const_iterator it = items.begin(); it != items.end(); ++it)
        {
            size_t pos = it->first.find_last_of('\\');
            if (pos != std::wstring::npos)
            {
                m_filelist.insert(it->first.substr(pos+1));
            }
        }
    }
    else if (items.size() == 1)
    {
        for (std::map<std::wstring, ULONG>::const_iterator it = items.begin(); it != items.end(); ++it)
        {
            size_t pos = it->first.find_last_of('\\');
            if (pos != std::wstring::npos)
            {
                m_filelist.insert(it->first.substr(pos+1));
            }
        }
    }
    else
    {
        // no files or only one file were selected.
        // use all files and folders in the current folder instead
        IServiceProvider * pServiceProvider = NULL;
        if (SUCCEEDED(GetIServiceProvider(hwnd, &pServiceProvider)))
        {
            IShellBrowser * pShellBrowser;
            if (SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser, IID_IShellBrowser, (LPVOID*)&pShellBrowser)))
            {
                IShellView * pShellView;
                if (SUCCEEDED(pShellBrowser->QueryActiveShellView(&pShellView)))
                {
                    IFolderView * pFolderView;
                    if (SUCCEEDED(pShellView->QueryInterface(IID_IFolderView, (LPVOID*)&pFolderView)))
                    {
                        // hooray! we got the IFolderView interface!
                        // that means the explorer is active and well :)

                        // but we also need the IShellFolder interface because
                        // we need its GetCurFolder() method
                        IPersistFolder2 * pPersistFolder;
                        if (SUCCEEDED(pFolderView->GetFolder(IID_IPersistFolder2, (LPVOID*)&pPersistFolder)))
                        {
                            LPITEMIDLIST folderpidl;
                            if (SUCCEEDED(pPersistFolder->GetCurFolder(&folderpidl)))
                            {
                                // we have the current folder
                                TCHAR buf[MAX_PATH] = {0};
                                // find the path of the folder
                                if (SHGetPathFromIDList(folderpidl, buf))
                                {
                                    m_currentDirectory = buf;
                                }
                                // if m_currentDirectory is empty here, that means
                                // the current directory is a virtual path

                                IShellFolder * pShellFolder;
                                if (SUCCEEDED(pPersistFolder->QueryInterface(IID_IShellFolder, (LPVOID*)&pShellFolder)))
                                {
                                    // find all selected items
                                    IEnumIDList * pEnum;
                                    if (SUCCEEDED(pFolderView->Items(SVGIO_ALLVIEW, IID_IEnumIDList, (LPVOID*)&pEnum)))
                                    {
                                        LPITEMIDLIST pidl;
                                        WCHAR buf[MAX_PATH] = {0};
                                        ULONG fetched = 0;
                                        ULONG attribs = 0;
                                        do
                                        {
                                            pidl = NULL;
                                            if (SUCCEEDED(pEnum->Next(1, &pidl, &fetched)))
                                            {
                                                if (fetched)
                                                {
                                                    // the pidl we get here is relative!
                                                    attribs = SFGAO_FILESYSTEM|SFGAO_FOLDER;
                                                    if (SUCCEEDED(pShellFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &attribs)))
                                                    {
                                                        if (attribs & SFGAO_FILESYSTEM)
                                                        {
                                                            // create an absolute pidl with the pidl we got above
                                                            LPITEMIDLIST abspidl = CPidl::Append(folderpidl, pidl);
                                                            if (abspidl)
                                                            {
                                                                if (SHGetPathFromIDList(abspidl, buf))
                                                                {
                                                                    std::wstring p = buf;
                                                                    size_t pos = p.find_last_of('\\');
                                                                    if (pos != std::wstring::npos)
                                                                    {
                                                                        m_filelist.insert(p.substr(pos+1));
                                                                    }
                                                                }
//.........这里部分代码省略.........
开发者ID:SpivEgin,项目名称:stexbar,代码行数:101,代码来源:Rename.cpp

示例10: convertKeyCode

MyGUI::KeyCode MYGUIManager::convertKeyCode( int key ) const
{
    static std::map<int, MyGUI::KeyCode> s_keyCodeMap;
    if ( !s_keyCodeMap.size() )
    {
		s_keyCodeMap['1'] = MyGUI::KeyCode::One;
		s_keyCodeMap['2'] = MyGUI::KeyCode::Two;
		s_keyCodeMap['3'] = MyGUI::KeyCode::Three;
		s_keyCodeMap['4'] = MyGUI::KeyCode::Four;
		s_keyCodeMap['5'] = MyGUI::KeyCode::Five;
		s_keyCodeMap['6'] = MyGUI::KeyCode::Six;
		s_keyCodeMap['7'] = MyGUI::KeyCode::Seven;
		s_keyCodeMap['8'] = MyGUI::KeyCode::Eight;
		s_keyCodeMap['9'] = MyGUI::KeyCode::Nine;
		s_keyCodeMap['0'] = MyGUI::KeyCode::Zero;

		s_keyCodeMap['a'] = MyGUI::KeyCode::A;
		s_keyCodeMap['b'] = MyGUI::KeyCode::B;
		s_keyCodeMap['c'] = MyGUI::KeyCode::C;
		s_keyCodeMap['d'] = MyGUI::KeyCode::D;
		s_keyCodeMap['e'] = MyGUI::KeyCode::E;
		s_keyCodeMap['f'] = MyGUI::KeyCode::F;
		s_keyCodeMap['g'] = MyGUI::KeyCode::G;
		s_keyCodeMap['h'] = MyGUI::KeyCode::H;
		s_keyCodeMap['i'] = MyGUI::KeyCode::I;
		s_keyCodeMap['j'] = MyGUI::KeyCode::J;
		s_keyCodeMap['k'] = MyGUI::KeyCode::K;
		s_keyCodeMap['l'] = MyGUI::KeyCode::L;
		s_keyCodeMap['m'] = MyGUI::KeyCode::M;
		s_keyCodeMap['n'] = MyGUI::KeyCode::N;
		s_keyCodeMap['o'] = MyGUI::KeyCode::O;
		s_keyCodeMap['p'] = MyGUI::KeyCode::P;
		s_keyCodeMap['q'] = MyGUI::KeyCode::Q;
		s_keyCodeMap['r'] = MyGUI::KeyCode::R;
		s_keyCodeMap['s'] = MyGUI::KeyCode::S;
		s_keyCodeMap['t'] = MyGUI::KeyCode::T;
		s_keyCodeMap['u'] = MyGUI::KeyCode::U;
		s_keyCodeMap['v'] = MyGUI::KeyCode::V;
		s_keyCodeMap['w'] = MyGUI::KeyCode::W;
		s_keyCodeMap['x'] = MyGUI::KeyCode::X;
		s_keyCodeMap['y'] = MyGUI::KeyCode::Y;
		s_keyCodeMap['z'] = MyGUI::KeyCode::Z;

		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F1] = MyGUI::KeyCode::F1;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F2] = MyGUI::KeyCode::F2;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F3] = MyGUI::KeyCode::F3;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F4] = MyGUI::KeyCode::F4;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F5] = MyGUI::KeyCode::F5;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F6] = MyGUI::KeyCode::F6;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F7] = MyGUI::KeyCode::F7;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F8] = MyGUI::KeyCode::F8;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F9] = MyGUI::KeyCode::F9;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_F10] = MyGUI::KeyCode::F10;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Escape] = MyGUI::KeyCode::Escape;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Tab] = MyGUI::KeyCode::Tab;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Return] = MyGUI::KeyCode::Return;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Space] = MyGUI::KeyCode::Space;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Minus] = MyGUI::KeyCode::Minus;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Equals] = MyGUI::KeyCode::Equals;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Backslash] = MyGUI::KeyCode::Backslash;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Slash] = MyGUI::KeyCode::Slash;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Semicolon] = MyGUI::KeyCode::Semicolon;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Comma] = MyGUI::KeyCode::Comma;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Period] = MyGUI::KeyCode::Period;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Insert] = MyGUI::KeyCode::Insert;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Delete] = MyGUI::KeyCode::Delete;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Home] = MyGUI::KeyCode::Home;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_End] = MyGUI::KeyCode::End;

		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Num_Lock] = MyGUI::KeyCode::NumLock;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Scroll_Lock] = MyGUI::KeyCode::ScrollLock;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Caps_Lock] = MyGUI::KeyCode::Capital;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_BackSpace] = MyGUI::KeyCode::Backspace;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Page_Down] = MyGUI::KeyCode::PageDown;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Page_Up] = MyGUI::KeyCode::PageUp;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Leftbracket] = MyGUI::KeyCode::LeftBracket;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Rightbracket] = MyGUI::KeyCode::RightBracket;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Quotedbl] = MyGUI::KeyCode::Apostrophe;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Left] = MyGUI::KeyCode::ArrowLeft;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Right] = MyGUI::KeyCode::ArrowRight;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Up] = MyGUI::KeyCode::ArrowUp;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Down] = MyGUI::KeyCode::ArrowDown;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_1] = MyGUI::KeyCode::Numpad1;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_2] = MyGUI::KeyCode::Numpad2;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_3] = MyGUI::KeyCode::Numpad3;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_4] = MyGUI::KeyCode::Numpad4;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_5] = MyGUI::KeyCode::Numpad5;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_6] = MyGUI::KeyCode::Numpad6;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_7] = MyGUI::KeyCode::Numpad7;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_8] = MyGUI::KeyCode::Numpad8;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_9] = MyGUI::KeyCode::Numpad9;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_0] = MyGUI::KeyCode::Numpad0;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_KP_Enter] = MyGUI::KeyCode::NumpadEnter;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Control_L] = MyGUI::KeyCode::LeftControl;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Control_R] = MyGUI::KeyCode::RightControl;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Alt_L] = MyGUI::KeyCode::LeftAlt;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Alt_R] = MyGUI::KeyCode::RightAlt;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Shift_L] = MyGUI::KeyCode::LeftShift;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Shift_R] = MyGUI::KeyCode::RightShift;
		s_keyCodeMap[osgGA::GUIEventAdapter::KEY_Num_Lock] = MyGUI::KeyCode::NumLock;
//.........这里部分代码省略.........
开发者ID:qqdiguo,项目名称:MuseOpenIG,代码行数:101,代码来源:MYGUIManager.cpp

示例11: read_matrix_and_rhs

int read_matrix_and_rhs(char *file_name, int &n, int &nnz,
  std::map<unsigned int, MatrixEntry> &mat, std::map<unsigned int, double> &rhs, bool &cplx_2_real)
{
  FILE *file = fopen(file_name, "r");
  if (file == NULL)
    return TEST_FAILURE;

  enum EState {
    STATE_N,
    STATE_MATRIX,
    STATE_RHS,
    STATE_NNZ
  }
  state = STATE_N;

  // Variables needed to turn complex matrix into real.
  int k = 0;
  int l = 0;
  double* rhs_buffer = NULL;

  double buffer[4];
  char row[MAX_ROW_LEN];
  while (fgets(row, MAX_ROW_LEN, file) != NULL) {
    switch (state) {
    case STATE_N:
      if (read_n_nums(row, 1, buffer)) {
        if (cplx_2_real) {
          n = 2*((int) buffer[0]);
          rhs_buffer = new double[n];
          for (int i = 0; i < n; i++) {
            rhs_buffer[i] = 0.0;
          }
        }
        else
          n = (int) buffer[0];

        state = STATE_NNZ;
      }
      break;

    case STATE_NNZ:
      if (read_n_nums(row, 1, buffer))
        nnz = (int) buffer[0];

      state = STATE_MATRIX;
      break;

    case STATE_MATRIX:
      if (cplx_2_real) {
        if (read_n_nums(row, 4, buffer)) {
          mat.insert(std::pair<unsigned int, MatrixEntry>(k,   MatrixEntry ((int) buffer[0],     (int) buffer[1],     buffer[2])));
          mat.insert(std::pair<unsigned int, MatrixEntry>(k + 1, MatrixEntry ((int) buffer[0] + n/2, (int) buffer[1],     buffer[3])));
          mat.insert(std::pair<unsigned int, MatrixEntry>(k + 2*nnz, MatrixEntry ((int) buffer[0],     (int) buffer[1] + n/2, (-1)*buffer[3])));
          mat.insert(std::pair<unsigned int, MatrixEntry>(k + 2*nnz + 1, MatrixEntry ((int) buffer[0] + n/2, (int) buffer[1] + n/2, buffer[2])));
          k = k + 2;
        }
        else
          state = STATE_RHS;
      }
      else { // if cplx_2_real is false.
        if (read_n_nums(row, 3, buffer))
          mat[mat.size()] = (MatrixEntry ((int) buffer[0], (int) buffer[1], buffer[2]));

        else
          state = STATE_RHS;
      }
      break; //case STATE_MATRIX break.

    case STATE_RHS:
      if (cplx_2_real) {
        if (read_n_nums(row, 3, buffer)) {

          if (buffer[0] != (int) n/2-1) // Then this is not the last line in the input file
          {
            rhs[((int) buffer[0])] = (double) buffer[1];
            rhs_buffer[l] = (double) buffer[2];
            l = l + 1;
          }

          else // This is last line in the file.
          {
            // First read last line entry
            rhs[((int) buffer[0])] = (double) buffer[1];
            rhs_buffer[l] = (double) buffer[2];
            l = l + 1;
            // Take imaginary parts you saved,
            // and fill the rest of the rhs vector.
            for (int i = 0; i < l; i++)
            {
              rhs[rhs.size()] = rhs_buffer[i];
            }
          }
        }
      }
      else { // if cplx_2_real is false.
        if (read_n_nums(row, 2, buffer))
          rhs[(int) buffer[0]] = (double) buffer[1];
      }
      break;
    }
//.........这里部分代码省略.........
开发者ID:JordanBlocher,项目名称:hermes,代码行数:101,代码来源:main.cpp

示例12:

static std::string key2symbol(SDLKey k, Uint16 unicode) {
  if(0==s_key2symbol.size()) {
    s_key2symbol[SDLK_BACKSPACE]="BackSpace";
    s_key2symbol[SDLK_TAB]="Tab";
    s_key2symbol[SDLK_CLEAR]="Clear";
    s_key2symbol[SDLK_RETURN]="Return";
    s_key2symbol[SDLK_PAUSE]="Pause";
    s_key2symbol[SDLK_ESCAPE]="Escape";
    s_key2symbol[SDLK_SPACE]="Space";
    s_key2symbol[SDLK_EXCLAIM]="!";
    s_key2symbol[SDLK_QUOTEDBL]="\"";
    s_key2symbol[SDLK_HASH]="#";
    s_key2symbol[SDLK_DOLLAR]="$";
    s_key2symbol[SDLK_AMPERSAND]="&";
    s_key2symbol[SDLK_QUOTE]="'";
    s_key2symbol[SDLK_LEFTPAREN]="(";
    s_key2symbol[SDLK_RIGHTPAREN]=")";
    s_key2symbol[SDLK_ASTERISK]="*";
    s_key2symbol[SDLK_PLUS]="+";
    s_key2symbol[SDLK_COMMA]=",";
    s_key2symbol[SDLK_MINUS]="-";
    s_key2symbol[SDLK_PERIOD]=".";
    s_key2symbol[SDLK_SLASH]="/";
    s_key2symbol[SDLK_0]="0";
    s_key2symbol[SDLK_1]="1";
    s_key2symbol[SDLK_2]="2";
    s_key2symbol[SDLK_3]="3";
    s_key2symbol[SDLK_4]="4";
    s_key2symbol[SDLK_5]="5";
    s_key2symbol[SDLK_6]="6";
    s_key2symbol[SDLK_7]="7";
    s_key2symbol[SDLK_8]="8";
    s_key2symbol[SDLK_9]="9";
    s_key2symbol[SDLK_COLON]=":";
    s_key2symbol[SDLK_SEMICOLON]=";";
    s_key2symbol[SDLK_LESS]="<";
    s_key2symbol[SDLK_EQUALS]="=";
    s_key2symbol[SDLK_GREATER]=">";
    s_key2symbol[SDLK_QUESTION]="?";
    s_key2symbol[SDLK_AT]="@";
    s_key2symbol[SDLK_LEFTBRACKET]="]";
    s_key2symbol[SDLK_BACKSLASH]="\\";
    s_key2symbol[SDLK_RIGHTBRACKET]="]";
    s_key2symbol[SDLK_CARET]="^";
    s_key2symbol[SDLK_UNDERSCORE]="_";
    s_key2symbol[SDLK_BACKQUOTE]="`";
    s_key2symbol[SDLK_a]="a";
    s_key2symbol[SDLK_b]="b";
    s_key2symbol[SDLK_c]="c";
    s_key2symbol[SDLK_d]="d";
    s_key2symbol[SDLK_e]="e";
    s_key2symbol[SDLK_f]="f";
    s_key2symbol[SDLK_g]="g";
    s_key2symbol[SDLK_h]="h";
    s_key2symbol[SDLK_i]="i";
    s_key2symbol[SDLK_j]="j";
    s_key2symbol[SDLK_k]="k";
    s_key2symbol[SDLK_l]="l";
    s_key2symbol[SDLK_m]="m";
    s_key2symbol[SDLK_n]="n";
    s_key2symbol[SDLK_o]="o";
    s_key2symbol[SDLK_p]="p";
    s_key2symbol[SDLK_q]="q";
    s_key2symbol[SDLK_r]="r";
    s_key2symbol[SDLK_s]="s";
    s_key2symbol[SDLK_t]="t";
    s_key2symbol[SDLK_u]="u";
    s_key2symbol[SDLK_v]="v";
    s_key2symbol[SDLK_w]="w";
    s_key2symbol[SDLK_x]="x";
    s_key2symbol[SDLK_y]="y";
    s_key2symbol[SDLK_z]="z";
    s_key2symbol[SDLK_DELETE]="Delete";

    s_worldkey2symbol[SDLK_WORLD_0]="World_0";
    s_worldkey2symbol[SDLK_WORLD_1]="World_1";
    s_worldkey2symbol[SDLK_WORLD_2]="World_2";
    s_worldkey2symbol[SDLK_WORLD_3]="World_3";
    s_worldkey2symbol[SDLK_WORLD_4]="World_4";
    s_worldkey2symbol[SDLK_WORLD_5]="World_5";
    s_worldkey2symbol[SDLK_WORLD_6]="World_6";
    s_worldkey2symbol[SDLK_WORLD_7]="World_7";
    s_worldkey2symbol[SDLK_WORLD_8]="World_8";
    s_worldkey2symbol[SDLK_WORLD_9]="World_9";
    s_worldkey2symbol[SDLK_WORLD_10]="World_10";
    s_worldkey2symbol[SDLK_WORLD_11]="World_11";
    s_worldkey2symbol[SDLK_WORLD_12]="World_12";
    s_worldkey2symbol[SDLK_WORLD_13]="World_13";
    s_worldkey2symbol[SDLK_WORLD_14]="World_14";
    s_worldkey2symbol[SDLK_WORLD_15]="World_15";
    s_worldkey2symbol[SDLK_WORLD_16]="World_16";
    s_worldkey2symbol[SDLK_WORLD_17]="World_17";
    s_worldkey2symbol[SDLK_WORLD_18]="World_18";
    s_worldkey2symbol[SDLK_WORLD_19]="World_19";
    s_worldkey2symbol[SDLK_WORLD_20]="World_20";
    s_worldkey2symbol[SDLK_WORLD_21]="World_21";
    s_worldkey2symbol[SDLK_WORLD_22]="World_22";
    s_worldkey2symbol[SDLK_WORLD_23]="World_23";
    s_worldkey2symbol[SDLK_WORLD_24]="World_24";
    s_worldkey2symbol[SDLK_WORLD_25]="World_25";
//.........这里部分代码省略.........
开发者ID:avilleret,项目名称:Gem,代码行数:101,代码来源:gemsdlwindow.cpp

示例13: abs

void NETWORK::load_network2(std::map<std::pair<std::string , std::string>,float> network, bool _weighted, int edges )
{
  // message file
  //std::string msg_file = _output + ".msg";
  //FILE *pMsg = NULL;

  // reset network
  for(int i=0; i<Order; i++)
    delete Nodes[i];
  Nodes.clear();
  Order = 0;
  Size = 0;

  // read edges
 // FILE_HANDLER f( _input_file.c_str(), "r" );
  //int edges = f.rows();
  //char line[1024] = {""};
  std::map<std::string, int> hash_table;
  int source, target;
  double weight;
  //char source_label[128] = {""};
  //char target_label[128] = {""};
  int source_id = 0;
  int target_id = 0;
  int columns;
  if (network.size() !=0)
  {
  std::map<std::pair<std::string , std::string>,float>::iterator it;
  for (std::map<std::pair<std::string , std::string>,float>::iterator it=network.begin(); it!=network.end(); ++it)
   {
    //f.get_text_line( line, sizeof(line) );
    //// check if line is valid (two or threee columns)
    //weight = 1.0;
    //columns = sscanf( line, "%s %s %lf", source_label, target_label, &weight );
    //if( (!_weighted && columns < 2) || (_weighted && columns != 3) )
    //{
    //  pMsg = fopen( msg_file.c_str(), "w" );
    //  fprintf( pMsg, "Error\nMissing column in line %i.", n+1 );
    //  fclose( pMsg );
    //  exit( 0 );
    //}
    std::pair< std::map<std::string, int>::iterator, bool> added;

    // source node
    added = hash_table.insert( std::pair<std::string, int>(std::string(it->first.first), (int)Nodes.size()) );
    if( added.second )
    {
      source_id = (int)Nodes.size();
	  add_node( it->first.first.c_str() );
    }
    else
      source_id = added.first->second;

    // target node
    added = hash_table.insert( std::pair<std::string, float>(std::string(it->first.second), (int)Nodes.size()) );
    if( added.second )
    {
      target_id = (int)Nodes.size();
      add_node( it->first.second.c_str());
    }
    else
      target_id = added.first->second;

    // add edge
    if( is_there_edge(source_id, target_id) )
    {
      weight += get_edge_weight( source_id, target_id );
      remove_edge(source_id, target_id);
      add_edge( source_id, target_id, abs(it->second)  );
    }
    else
      add_edge( source_id, target_id, abs(it->second) );
  }
}

  // if size limitazion is on, check network size
  //if( _size_limit != 0 && Order > _size_limit )
  //{
  //  pMsg = fopen( msg_file.c_str(), "w" );
  //  fprintf( pMsg, "Error\nNetwork is too large." );
  //  fclose( pMsg );
  //  exit(0);
  //}

  // normalize weights
  // uncomment this part for normal hierarchy computation
  // this commented out for no weight hierarchy computation
  /*int deg;
  double max_weight = Nodes[0]->outweight(0);
  for(int i=0; i<Order; i++)
  {
    deg = Nodes[i]->outdegree();
    for(int j=0; j<deg; j++)
    {
      if( Nodes[i]->outweight(j) > max_weight )
        max_weight = Nodes[i]->outweight(j);
    }
  }
  for(int i=0; i<Order; i++)
  {
//.........这里部分代码省略.........
开发者ID:gandalfvn,项目名称:EOH,代码行数:101,代码来源:network.cpp

示例14: LoadBitmap

BOOL CBitmap::LoadBitmap(LPCTSTR lpszResourceName)
{
    if (g_mapResBitMaps.size() == 0)
    {
        QString resPath = QDir::currentPath();
        QDomDocument doc;
        QFile file(resPath + "\\Resources.xml");
        int errorLine, errorColumn;
        QString errorMsg;

        if (!file.open(QIODevice::ReadOnly))
        {
           return FALSE;
        }

        if (!doc.setContent(&file, &errorMsg, &errorLine, &errorColumn))
        {
            file.close();
            return FALSE;
        }

        file.close();

        /*
         *
         *<BITMAPTABLE>
        <BITMAP IDSTR="IDR_MAINFRAME" ID="128" NAME="Toolbar.bmp"/>
      </BITMAPTABLE>
      */

        QDomElement docElem = doc.documentElement();

        QDomElement bitmapTable = docElem.firstChildElement("BITMAPTABLE");

        while(!bitmapTable.isNull())
        {
            QDomElement bitmapTableItem = bitmapTable.firstChildElement("BITMAP");

            while(!bitmapTableItem.isNull())
            {
                QDomNamedNodeMap attrs = bitmapTableItem.attributes();

                QDomNode idAttr = attrs.namedItem("ID");
                QDomNode idStrAttr = attrs.namedItem("IDSTR");
                QDomNode nameAttr = attrs.namedItem("NAME");

                QString resPath = QDir::currentPath();
                QString imagePath = resPath + "\\" + nameAttr.nodeValue();
                QPixmap *image = new QPixmap;

                if (image->load(imagePath))
                {
                    if (!idAttr.isNull())
                    {
                        g_mapResBitMaps[idAttr.nodeValue()] = image;
                    }
                    else
                    if (!idStrAttr.isNull())
                    {
                        g_mapResBitMaps[idStrAttr.nodeValue()] = image;
                    }
                }
                else
                {
                    delete image;
                }

                bitmapTableItem = bitmapTableItem.nextSiblingElement("BITMAP");
            }

            bitmapTable = bitmapTable.nextSiblingElement("BITMAPTABLE");
        }
    }

    if (mBitMap)
    {
        QPixmap *bitmap = (QPixmap *)mBitMap;
        delete bitmap;
    }

    if (g_mapResBitMaps.find(QString::fromWCharArray(lpszResourceName)) != g_mapResBitMaps.end())
    {
        mBitMap = new QPixmap(*(g_mapResBitMaps[QString::fromWCharArray(lpszResourceName)]));
    }

    return mBitMap != NULL;
}
开发者ID:mdmitry1973,项目名称:CShell,代码行数:87,代码来源:CBitmap.cpp

示例15: apply

void OpenCLConfig::apply(std::string &_devTy, std::map<cl_device_id, cl_context>& _devices)
{
    _devicesPtr=&_devices;
    //Auto-enable CUDA if it was not done before
   if (!_enableOpenCL) {
       //ompss_uses_opencl pointer will be null (is extern) if the compiler did not fill it
      _enableOpenCL=((&ompss_uses_opencl)!=0);
   }
   if( _forceDisableOpenCL || !_enableOpenCL ) 
     return;

   cl_int errCode;

   // Get the number of available platforms.
   cl_uint numPlats;
   if( clGetPlatformIDs( 0, NULL, &numPlats ) != CL_SUCCESS )
      fatal0( "Cannot detect the number of available OpenCL platforms" );

   if ( numPlats == 0 )
      fatal0( "No OpenCL platform available" );

   // Read all platforms.
   cl_platform_id *plats = new cl_platform_id[numPlats];
   if( clGetPlatformIDs( numPlats, plats, NULL ) != CL_SUCCESS )
      fatal0( "Cannot load OpenCL platforms" );

   // Is platform available?
   if( !numPlats )
      fatal0( "No OpenCL platform available" );

   std::vector<cl_platform_id> _plats;
   // Save platforms.
   _plats.assign(plats, plats + numPlats);
   delete [] plats;

   cl_device_type devTy;

   // Parse the requested device type.
   if( _devTy == "" || _devTy == "ALL" )
      devTy = CL_DEVICE_TYPE_ALL;
   else if( _devTy == "CPU" )
      devTy = CL_DEVICE_TYPE_CPU;
   else if( _devTy == "GPU" )
      devTy = CL_DEVICE_TYPE_GPU;
   else if( _devTy == "ACCELERATOR" )
      devTy = CL_DEVICE_TYPE_ACCELERATOR;
   else
      fatal0( "Unable to parse device type" );

   // Read all devices.
   for( std::vector<cl_platform_id>::iterator i = _plats.begin(),
                                              e = _plats.end();
                                              i != e;
                                              ++i ) {
      #ifndef NANOS_DISABLE_ALLOCATOR
         char buffer[200];
         clGetPlatformInfo(*i, CL_PLATFORM_VENDOR, 200, buffer, NULL);
         if (std::string(buffer)=="Intel(R) Corporation" || std::string(buffer)=="ARM"){
            debug0("Intel or ARM OpenCL don't work correctly when using nanox allocator, "
                    "please configure and reinstall nanox with --disable-allocator in case you want to use it, skipping Intel OpenCL devices");
            continue;
         }
      #endif
      // Get the number of available devices.
      cl_uint numDevices;
      errCode = clGetDeviceIDs( *i, devTy, 0, NULL, &numDevices );

      if( errCode != CL_SUCCESS )
         continue;

      // Read all matching devices.
      cl_device_id *devs = new cl_device_id[numDevices];
      errCode = clGetDeviceIDs( *i, devTy, numDevices, devs, NULL );
      if( errCode != CL_SUCCESS )
         continue;

      int devicesToUse=0;   
      cl_device_id *avaiableDevs = new cl_device_id[numDevices];
      // Get all avaiable devices
      for( cl_device_id *j = devs, *f = devs + numDevices; j != f; ++j )
      {
         cl_bool available;

         errCode = clGetDeviceInfo( *j,
                                      CL_DEVICE_AVAILABLE,
                                      sizeof( cl_bool ),
                                      &available,
                                      NULL );
         if( errCode != CL_SUCCESS )
           continue;

         if( available && _devices.size()+devicesToUse<_devNum){
             avaiableDevs[devicesToUse++]=*j;
         }
      }
      
      cl_context_properties props[] =
      {  CL_CONTEXT_PLATFORM,
         reinterpret_cast<cl_context_properties>(*i),
         0
//.........这里部分代码省略.........
开发者ID:robbriggs,项目名称:masters-project-nanosxx,代码行数:101,代码来源:openclconfig.cpp


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