• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ end函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中end函数的典型用法代码示例。如果您正苦于以下问题:C++ end函数的具体用法?C++ end怎么用?C++ end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: find

/** \throw NonexistentParameterAccessed if \p name is not a key. */
ParameterMap::iterator ParameterMap::findOrThrow(const std::string& name) {
  map_type::iterator it = find(name);
  if (it != end()) return it;
  throw ParameterMap::NonexistentParameterAccessed(name, *this);
}
开发者ID:lene,项目名称:HyperspaceExplorer,代码行数:6,代码来源:ParameterMap.C


示例2: operator

 std::pair<I, O> operator()(Rng &rng, O out, P proj = P{}) const
 {
     return (*this)(begin(rng), end(rng), std::move(out), std::move(proj));
 }
开发者ID:cordarei,项目名称:range-v3,代码行数:4,代码来源:copy_backward.hpp


示例3: end

SimpleAudioEngineOpenSL::~SimpleAudioEngineOpenSL()
{
	end();
}
开发者ID:1007650105,项目名称:RockChipmunk2D,代码行数:4,代码来源:SimpleAudioEngineOpenSL.cpp


示例4: Fl_Group

/*     Fl_Group( X, Y, W, H, L) */
Chain::Chain ( ) : Fl_Group( 0, 0, 100, 100, "")

{
    /* not really deleting here, but reusing this variable */
    _deleting = true;

    int X = 0;
    int Y = 0;
    int W = 100;
    int H = 100;

/*     _outs = 1; */
/*     _ins = 1; */

    _configure_outputs_callback = NULL;

    _strip = NULL;

    _name = NULL;

    labelsize( 10 );
    align( FL_ALIGN_TOP );

    { Fl_Flip_Button* o  = tab_button = new Fl_Flip_Button( X, Y, W, 16, "chain/controls");
        o->type(1);
        o->labelsize( 12 );
        o->callback( cb_handle, this );
    }

    Y += 18;
    H -= 18;

    { Fl_Group *o = chain_tab = new Fl_Group( X, Y, W, H, "" );
        o->labeltype( FL_NO_LABEL );
        o->box( FL_FLAT_BOX );
//        o->color( fl_darker( FL_BACKGROUND_COLOR ) );
//        o->color( FL_BACKGROUND_COLOR );
//        o->box( FL_NO_BOX );
        { Fl_Packscroller *o = new Fl_Packscroller( X, Y, W, H );
            o->color( FL_BACKGROUND_COLOR );
//            o->box( FL_FLAT_BOX );
            o->box( FL_THIN_UP_BOX );
            o->type( Fl_Scroll::VERTICAL );
            { Fl_Pack *o = modules_pack = new Fl_Pack( X, Y, W, H );
                o->type( Fl_Pack::VERTICAL );
                o->spacing( 6 );
                o->end();
                Fl_Group::current()->resizable( o );
            }
            o->end();
        }
        o->end();
    }
    { Fl_Group *o = control_tab = new Fl_Group( X, Y, W, H, "" );
        o->box( FL_FLAT_BOX );
        o->color( FL_BACKGROUND_COLOR );
        o->labeltype( FL_NO_LABEL );
        o->hide();
        { Fl_Scroll *o = new Fl_Scroll( X, Y, W, H );
            o->color( FL_BACKGROUND_COLOR );
            o->box( FL_NO_BOX );
            o->type( Fl_Scroll::VERTICAL );
            { Fl_Pack *o = controls_pack = new Fl_Pack( X, Y, W, H );
                o->type( Fl_Pack::VERTICAL );
                o->spacing( 5 );
//            o->color( FL_RED );
                o->end();
                Fl_Group::current()->resizable( o );
            }
            o->end();
            Fl_Group::current()->resizable( o );
        }
        o->end();
        o->hide();
        Fl_Group::current()->resizable( o );
    }
    end();

    log_create();

    _deleting = false;
}
开发者ID:0mk,项目名称:non,代码行数:83,代码来源:Chain.C


示例5: furn_item

void inventory::form_from_map( const tripoint &origin, int range, bool assign_invlet )
{
    items.clear();
    for( const tripoint &p : g->m.points_in_radius( origin, range ) ) {
        if (g->m.has_furn( p ) && g->m.accessible_furniture( origin, p, range )) {
            const furn_t &f = g->m.furn_at( p );
            itype *type = f.crafting_pseudo_item_type();
            if (type != NULL) {
                item furn_item(type->id, 0);
                const itype *ammo = f.crafting_ammo_item_type();
                if (ammo != NULL) {
                    furn_item.charges = count_charges_in_list( ammo, g->m.i_at( p ) );
                }
                furn_item.item_tags.insert("PSEUDO");
                add_item(furn_item);
            }
        }
        if( !g->m.accessible_items( origin, p, range ) ) {
            continue;
        }
        for (auto &i : g->m.i_at( p )) {
            if (!i.made_of(LIQUID)) {
                add_item(i, false, assign_invlet);
            }
        }
        // Kludges for now!
        ter_id terrain_id = g->m.ter( p );
        if (g->m.has_nearby_fire( p, 0 )) {
            item fire("fire", 0);
            fire.charges = 1;
            add_item(fire);
        }
        if (terrain_id == t_water_sh || terrain_id == t_water_dp ||
            terrain_id == t_water_pool || terrain_id == t_water_pump) {
            item water("water", 0);
            water.charges = 50;
            add_item(water);
        }
        if (terrain_id == t_swater_sh || terrain_id == t_swater_dp) {
            item swater("salt_water", 0);
            swater.charges = 50;
            add_item(swater);
        }
        // add cvd forge from terrain
        if (terrain_id == t_cvdmachine) {
            item cvd_machine("cvd_machine", 0);
            cvd_machine.charges = 1;
            cvd_machine.item_tags.insert("PSEUDO");
            add_item(cvd_machine);
        }
        // kludge that can probably be done better to check specifically for toilet water to use in
        // crafting
        if (g->m.furn_at( p ).examine == &iexamine::toilet) {
            // get water charges at location
            auto toilet = g->m.i_at( p );
            auto water = toilet.end();
            for( auto candidate = toilet.begin(); candidate != toilet.end(); ++candidate ) {
                if( candidate->typeId() == "water" ) {
                    water = candidate;
                    break;
                }
            }
            if( water != toilet.end() && water->charges > 0) {
                add_item( *water );
            }
        }

        // keg-kludge
        if (g->m.furn_at( p ).examine == &iexamine::keg) {
            auto liq_contained = g->m.i_at( p );
            for( auto &i : liq_contained ) {
                if( i.made_of(LIQUID) ) {
                    add_item(i);
                }
            }
        }

        // WARNING: The part below has a bug that's currently quite minor
        // When a vehicle has multiple faucets in range, available water is
        //  multiplied by the number of faucets.
        // Same thing happens for all other tools and resources, but not cargo
        int vpart = -1;
        vehicle *veh = g->m.veh_at( p, vpart );

        if( veh == nullptr ) {
            continue;
        }

        //Adds faucet to kitchen stuff; may be horribly wrong to do such....
        //ShouldBreak into own variable
        const int kpart = veh->part_with_feature(vpart, "KITCHEN");
        const int faupart = veh->part_with_feature(vpart, "FAUCET");
        const int weldpart = veh->part_with_feature(vpart, "WELDRIG");
        const int craftpart = veh->part_with_feature(vpart, "CRAFTRIG");
        const int forgepart = veh->part_with_feature(vpart, "FORGE");
        const int chempart = veh->part_with_feature(vpart, "CHEMLAB");
        const int cargo = veh->part_with_feature(vpart, "CARGO");

        if (cargo >= 0) {
            *this += std::list<item>( veh->get_items(cargo).begin(),
//.........这里部分代码省略.........
开发者ID:NateBrune,项目名称:Cataclysm-DDA,代码行数:101,代码来源:inventory.cpp


示例6:

//--------------------------------------------------
ofBuffer::ofBuffer()
:currentLine(end(),end()){
	buffer.resize(1);
}
开发者ID:sleliyk,项目名称:openFrameworks,代码行数:5,代码来源:ofFileUtils.cpp


示例7: find

std::string WizardImpl::searchForSpell(std::string const &wish) {
	auto const spell = find(begin(books), end(books), wish);
	return spell!=end(books)?*spell:"";
}
开发者ID:PeterSommerlad,项目名称:CPlusPlusLecture,代码行数:4,代码来源:WizardPimpl.cpp


示例8: return

bool UniString::IsEqualAscii(char const * s) const
{
  return (size() == strlen(s) && equal(begin(), end(), s));
}
开发者ID:DINKIN,项目名称:omim,代码行数:4,代码来源:string_utils.cpp


示例9: main

int main()
{
    try {
        enum pubnub_res res;
        std::string chan("hello_world");
        pubnub::context pb("demo", "demo");
 
        /* Leave this commented out to use the default - which is
           blocking I/O on most platforms. Uncomment to use non-
           blocking I/O.
        */
       pb.set_blocking_io(pubnub::non_blocking);
        
        if (0 != pb.set_uuid_v4_random()) {
            pb.set_uuid("zeka-peka-iz-jendeka");
        }
        else {
            std::cout << "Generated UUID: " << pb.uuid() << std::endl;
        }
        pb.set_auth("danaske");

        pb.set_transaction_timeout(
#if __cplusplus >= 201103L
            std::chrono::seconds(10)
#else
            10000
#endif
            );

        std::cout << "First subscribe / connect" << std::endl;
        if (PNR_OK ==  pb.subscribe(chan).await()) {
            std::cout << "Subscribe/connected!" << std::endl;
        }
        else {
            std::cout << "Subscribe failed!" << std::endl;
        }

#if PUBNUB_CRYPTO_API
        std::cout << "Publishing encrypted" << std::endl;
        pubnub::futres futres = pb.publish_encrypted(chan, "\"Hello world from C++!\"", "KUKUMENEGRDNA");
#else
        std::cout << "Publishing" << std::endl;
        pubnub::futres futres = pb.publish(chan, "\"Hello world from C++!\"");
#endif
        res = futres.await();
        if (PNR_OK == res) {
            std::cout << "Published! Response from Pubnub: " << pb.last_publish_result() << std::endl;
        }
        else if (PNR_PUBLISH_FAILED == res) {
            std::cout << "Published failed on Pubnub, description: " << pb.last_publish_result() << std::endl;
        }
        else {
            std::cout << "Publishing failed with code: " << res << std::endl;
        }

        std::cout << "Subscribing" << std::endl;
        if (PNR_OK ==  pb.subscribe(chan).await()) {
            std::cout << "Subscribed! Got messages:" << std::endl;
            /// Lets illustrate getting all the message in a vector,
            /// and iterating over it
#if __cplusplus >= 201103L
#if PUBNUB_CRYPTO_API
            auto msg = pb.get_all_decrypted("KUKUMENEGRDNA");
#else
            auto msg = pb.get_all();
#endif
            for (auto it = msg.begin(); it != msg.end(); ++it) {
                std::cout << *it << std::endl;
            }
#else
#if PUBNUB_CRYPTO_API
            std::vector<std::string> msg = pb.get_all_decrypted("KUKUMENEGRDNA");
#else
            std::vector<std::string> msg = pb.get_all();
#endif
            for (std::vector<std::string>::iterator it = msg.begin(); it != msg.end(); ++it) {
                std::cout << *it << std::endl;
            }
#endif
        }
        else {
            std::cout << "Subscribe failed!" << std::endl;
        }

        std::cout << "Getting time" << std::endl;
        if (PNR_OK ==  pb.time().await()) {
            std::cout << "Gotten time " << pb.get() << "; last time token="<< pb.last_time_token() << std::endl;
        }
        else {
            std::cout << "Getting time failed!" << std::endl;
        }

        std::cout << "Getting history" << std::endl;
        res = pb.history(chan).await();
        if (PNR_OK ==  res) {
            std::cout << "Got history! Messages:" << std::endl;
            /// Lets illustrate getting all the message in a vector,
            /// and then accessing each vector index in a loop
#if __cplusplus >= 201103L
            auto msg = pb.get_all();
//.........这里部分代码省略.........
开发者ID:sveljko,项目名称:c-core,代码行数:101,代码来源:pubnub_sample.cpp


示例10: emit_class

void emit_class(EmitUnitState& state,
                UnitEmitter& ue,
                const php::Class& cls) {
  FTRACE(2, "    class: {}\n", cls.name->data());
  auto const pce = ue.newPreClassEmitter(
    cls.name,
    cls.hoistability
  );
  pce->init(
    std::get<0>(cls.srcInfo.loc),
    std::get<1>(cls.srcInfo.loc),
    ue.bcPos(),
    cls.attrs,
    cls.parentName ? cls.parentName : s_empty.get(),
    cls.srcInfo.docComment
  );
  pce->setUserAttributes(cls.userAttributes);

  for (auto& x : cls.interfaceNames)     pce->addInterface(x);
  for (auto& x : cls.usedTraitNames)     pce->addUsedTrait(x);
  for (auto& x : cls.requirements)       pce->addClassRequirement(x);
  for (auto& x : cls.traitPrecRules)     pce->addTraitPrecRule(x);
  for (auto& x : cls.traitAliasRules)    pce->addTraitAliasRule(x);

  for (auto& m : cls.methods) {
    FTRACE(2, "    method: {}\n", m->name->data());
    auto const fe = ue.newMethodEmitter(m->name, pce);
    emit_init_func(*fe, *m);
    pce->addMethod(fe);
    auto const info = emit_bytecode(state, ue, *m);
    emit_finish_func(*m, *fe, info);
  }

  auto const privateProps   = state.index.lookup_private_props(&cls);
  auto const privateStatics = state.index.lookup_private_statics(&cls);
  for (auto& prop : cls.properties) {
    auto const repoTy = [&] (const PropState& ps) -> RepoAuthType {
      // TODO(#3599292): we don't currently infer closure use var types.
      if (is_closure(cls)) return RepoAuthType{};
      auto it = ps.find(prop.name);
      if (it == end(ps)) return RepoAuthType{};
      auto const rat = make_repo_type(*state.index.array_table_builder(),
                                      it->second);
      merge_repo_auth_type(ue, rat);
      return rat;
    };

    pce->addProperty(
      prop.name,
      prop.attrs,
      prop.typeConstraint,
      prop.docComment,
      &prop.val,
      (prop.attrs & AttrStatic) ? repoTy(privateStatics) : repoTy(privateProps)
    );
  }

  for (auto& cconst : cls.constants) {
    pce->addConstant(
      cconst.name,
      cconst.typeConstraint,
      &cconst.val,
      cconst.phpCode
    );
  }

  pce->setEnumBaseTy(cls.enumBaseTy);
}
开发者ID:Ruwan-Ranganath,项目名称:hhvm,代码行数:68,代码来源:emit.cpp


示例11: emit_ehent_tree


//.........这里部分代码省略.........
    auto const parent = activeList.empty()
      ? nullptr
      : borrow(exnMap[activeList.back()].back());
    exnMap[p].push_back(
      folly::make_unique<EHRegion>(
        EHRegion { p, parent, start, kInvalidOffset }
      )
    );
    activeList.push_back(p);
  };

  /*
   * Walk over the blocks, and compare the new block's exnNode path to
   * the active one.  Find the least common ancestor of the two paths,
   * then modify the active list by popping and then pushing nodes to
   * set it to the new block's path.
   */
  for (auto& b : info.blockOrder) {
    auto const offset = info.blockInfo[b->id].offset;

    if (!b->exnNode) {
      while (!activeList.empty()) pop_active(offset);
      continue;
    }

    std::vector<borrowed_ptr<const php::ExnNode>> current;
    exn_path(current, b->exnNode);

    auto const prefix = shared_prefix(current, activeList);
    for (size_t i = prefix, sz = activeList.size(); i < sz; ++i) {
      pop_active(offset);
    }
    for (size_t i = prefix, sz = current.size(); i < sz; ++i) {
      push_active(current[i], offset);
    }

    if (debug && !activeList.empty()) {
      current.clear();
      exn_path(current, activeList.back());
      assert(current == activeList);
    }
  }

  while (!activeList.empty()) {
    pop_active(info.blockInfo[info.blockOrder.back()->id].past);
  }

  /*
   * We've created all our regions, but we need to sort them instead
   * of trying to get the UnitEmitter to do it.
   *
   * The UnitEmitter expects EH regions that look a certain way
   * (basically the way emitter.cpp likes them).  There are some rules
   * about the order it needs to have at runtime, which we set up
   * here.
   *
   * Essentially, an entry a is less than an entry b iff:
   *
   *   - a starts before b
   *   - a starts at the same place, but encloses b entirely
   *   - a has the same extents as b, but is a parent of b
   */
  std::vector<borrowed_ptr<EHRegion>> regions;
  for (auto& mapEnt : exnMap) {
    for (auto& region : mapEnt.second) {
      regions.push_back(borrow(region));
    }
  }
  std::sort(
    begin(regions), end(regions),
    [&] (borrowed_ptr<const EHRegion> a, borrowed_ptr<const EHRegion> b) {
      if (a == b) return false;
      if (a->start == b->start) {
        if (a->past == b->past) {
          // When regions exactly overlap, the parent is less than the
          // child.
          for (auto p = b->parent; p != nullptr; p = p->parent) {
            if (p == a) return true;
          }
          // If a is not a parent of b, and they have the same region;
          // then b better be a parent of a.
          if (debug) {
            auto p = a->parent;
            for (; p != b && p != nullptr; p = p->parent) continue;
            assert(p == b);
          }
          return false;
        }
        return a->past > b->past;
      }
      return a->start < b->start;
    }
  );

  std::map<borrowed_ptr<const EHRegion>,uint32_t> parentIndexMap;
  for (auto& r : regions) {
    emit_eh_region(fe, r, info.blockInfo, parentIndexMap);
  }
  fe.setEHTabIsSorted();
}
开发者ID:Ruwan-Ranganath,项目名称:hhvm,代码行数:101,代码来源:emit.cpp


示例12: setpg

 inline void setpg(char_type * pp, char_type * gp)
 {
     setp(pp, end());
     setg(gp, gp, pp);
 }
开发者ID:xzmagic,项目名称:Bex,代码行数:5,代码来源:static_streambuf.hpp


示例13: operator

 std::pair<I, O>
 operator()(Rng &rng, ORng &result, BOp bop = BOp{}, P proj = P{}) const
 {
     return (*this)(begin(rng), end(rng), begin(result), end(result),
                    std::move(bop), std::move(proj));
 }
开发者ID:morinmorin,项目名称:range-v3,代码行数:6,代码来源:adjacent_difference.hpp


示例14: sizeof

bool Bitmap_Handler::export_image(Image_8 * image, const char * file_name) 
{
	auto output = std::ofstream{ file_name, std::ios::binary };

	output << "BM";
	//File Size Parameter
	uint32_t var_32_u = 54 + 3 * image->get_pixels()->size(); 
	for (int i = 0; i < ((image->size_x * 3) % 4); i++) {
		var_32_u += image->size_y;
	}
	output.write( (char*) &var_32_u, sizeof(var_32_u));
	//Reserved
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Image offset
	var_32_u = 54;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Infoheader Size
	var_32_u = 40;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Width
	int32_t var_32_s = image->size_x;
	output.write((char*)&var_32_s, sizeof(var_32_s));
	//Height
	var_32_s = image->size_y;
	output.write((char*)&var_32_s, sizeof(var_32_s));
	//Unused
	uint16_t var_16_u = 1;
	output.write((char*)&var_16_u, sizeof(var_16_u));
	//biBitCount
	var_16_u = 24;
	output.write((char*)&var_16_u, sizeof(var_16_u));
	//Compression
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//SizeImage
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Pixels per Meter
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Color Table
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));
	//Colors used
	var_32_u = 0;
	output.write((char*)&var_32_u, sizeof(var_32_u));

	unsigned int row_ind = 0;

	auto pixels = image->get_pixels();

	unsigned int z = 0;

	for (auto it = pixels->begin(); it != pixels->end(); it++) {
		int t_r = (*it).get_r();
		output.write((char*)&(t_r), 1);
		int t_g = (*it).get_g();
		output.write((char*)&(t_g), 1);
		int t_b = (*it).get_b();
		output.write((char*)&(t_b), 1);
		row_ind += 3;
		z++;
		//Catch last Bytes in Row
		if (z == (image->size_x)) {
			while (row_ind % 4 != 0) { 
				row_ind++; 
				uint8_t t_a = 0;
				output.write((char*)&t_a, 1);
			}
			row_ind = 0;
			z = 0;
		}
	}

	output.close();

	return true;
}
开发者ID:hanneskiene,项目名称:Image_Processor,代码行数:80,代码来源:Bitmap_Handler.cpp


示例15: while

void MobileSimulator::MouseUpEvent(Vec2i screenCoordinates, MouseButtonInput button)
{
	_multiGestureOngoing = false;
	_gestureType = NONE;
	_mouseDown = false;

	TouchList* tl = &TouchListener::GetTouchList();
	
	if (theInput.IsKeyDown(ANGEL_KEY_LEFTCONTROL) || theInput.IsKeyDown(ANGEL_KEY_RIGHTCONTROL))
	{
		TouchList::iterator it = tl->begin();
		while (it != tl->end())
		{
			SendTouchNotifiers((*it), TOUCH_END);
			delete (*it);
			it = tl->erase(it);
		}
	}
	else
	{
		// just a single touch, but we'll iterate anyway
		TouchList::iterator it = tl->begin();
		while (it != tl->end())
		{
			if ( (theWorld.GetCurrentTimeSeconds() - (*it)->MotionStartTime) < SWIPE_MAX_DURATION)
			{
				Vector2 start((*it)->StartingPoint);
				Vector2 end((*it)->CurrentPoint);
				Vector2 motion = end - start;
				if (motion.LengthSquared() >= (SWIPE_MIN_DISTANCE * SWIPE_MIN_DISTANCE))
				{
					float angle = MathUtil::ToDegrees(acos(Vector2::Dot(Vector2::UnitX, Vector2::Normalize(motion))));
					if (motion.Y > 0.0f)
					{
						angle = 360.0f - angle;
					}

					if      ( (angle > 45.0f) && (angle <= 135.0f) )
					{
						// swipe up
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeUp"));
					}
					else if ( (angle > 135.0f) && (angle <= 225.0f) )
					{
						// swipe left
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeLeft"));
					}
					else if ( (angle > 225.0f) && (angle <= 315.0f) )
					{
						// swipe down
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeDown"));
					}
					else
					{
						// swipe right
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeRight"));
					}
				}
			}
			SendTouchNotifiers((*it), TOUCH_END);
			delete (*it);
			it = tl->erase(it);
		}
	}
}
开发者ID:MrSnowman,项目名称:angel2d,代码行数:65,代码来源:MobileSimulator.cpp


示例16: merge_bytes_unsigned

std::shared_ptr<Image_8> Bitmap_Handler::get_Image(const char * file_name)
{

	auto input = std::ifstream{ file_name, std::ios::binary };
	if (input.is_open()) {

		// get length of file:
		input.seekg(0, input.end);
		unsigned long length = input.tellg();
		input.seekg(0, input.beg);

		if (length > 50) {

			//Should be replaced by an import into a vector
			char *buffer = new char[length];
			input.read(buffer, length);

			auto data_offset = merge_bytes_unsigned(buffer, 10, 4);

			auto size_x = merge_bytes_unsigned(buffer, 18, 4);

			auto size_y = merge_bytes_unsigned(buffer, 22, 4);

			auto biBitCount = merge_bytes_unsigned(buffer, 28, 2);

			auto bCompression = merge_bytes_unsigned(buffer, 30, 24);

			auto output = std::make_shared<Image_8>(size_x, size_y);

			unsigned long index = data_offset;

			unsigned int row_ind = 0;

			auto pixels = output->get_pixels();

			unsigned int z = 0;

			for (auto it = pixels->begin(); it != pixels->end(); it++) {
				(*it).set_RGB((unsigned char)(buffer[index]),(unsigned char)(buffer[index + 1]),(unsigned char)(buffer[index + 2]));
				index += 3;
				row_ind += 3;
				z++;
				//Catch last Bytes in Row
				if (z == (size_x)) {
					while (row_ind % 4 != 0) { index++; row_ind++; }
					row_ind = 0;
					z = 0;
				}
			}

			input.close();

			delete[] buffer;

			return output;
		}
	}
	else {
		return std::make_shared<Image_8>(0, 0);
		std::cout << "Image not found" << std::endl;
	}
}
开发者ID:hanneskiene,项目名称:Image_Processor,代码行数:62,代码来源:Bitmap_Handler.cpp


示例17: clip_to_bounds

std::vector<tripoint> map::route( const tripoint &f, const tripoint &t,
                                  const pathfinding_settings &settings,
                                  const std::set<tripoint> &pre_closed ) const
{
    /* TODO: If the origin or destination is out of bound, figure out the closest
     * in-bounds point and go to that, then to the real origin/destination.
     */
    std::vector<tripoint> ret;

    if( f == t || !inbounds( f ) ) {
        return ret;
    }

    if( !inbounds( t ) ) {
        tripoint clipped = t;
        clip_to_bounds( clipped );
        return route( f, clipped, settings, pre_closed );
    }
    // First, check for a simple straight line on flat ground
    // Except when the line contains a pre-closed tile - we need to do regular pathing then
    constexpr auto non_normal = PF_SLOW | PF_WALL | PF_VEHICLE | PF_TRAP;
    if( f.z == t.z ) {
        const auto line_path = line_to( f, t );
        const auto &pf_cache = get_pathfinding_cache_ref( f.z );
        // Check all points for any special case (including just hard terrain)
        if( std::all_of( line_path.begin(), line_path.end(), [&pf_cache, non_normal]( const tripoint & p ) {
        return !( pf_cache.special[p.x][p.y] & non_normal );
        } ) ) {
            const std::set<tripoint> sorted_line( line_path.begin(), line_path.end() );

            if( is_disjoint( sorted_line, pre_closed ) ) {
                return line_path;
            }
        }
    }

    // If expected path length is greater than max distance, allow only line path, like above
    if( rl_dist( f, t ) > settings.max_dist ) {
        return ret;
    }

    int max_length = settings.max_length;
    int bash = settings.bash_strength;
    bool doors = settings.allow_open_doors;
    bool trapavoid = settings.avoid_traps;

    const int pad = 16;  // Should be much bigger - low value makes pathfinders dumb!
    int minx = std::min( f.x, t.x ) - pad;
    int miny = std::min( f.y, t.y ) - pad;
    int minz = std::min( f.z, t.z ); // TODO: Make this way bigger
    int maxx = std::max( f.x, t.x ) + pad;
    int maxy = std::max( f.y, t.y ) + pad;
    int maxz = std::max( f.z, t.z ); // Same TODO as above
    clip_to_bounds( minx, miny, minz );
    clip_to_bounds( maxx, maxy, maxz );

    pathfinder pf( minx, miny, maxx, maxy );
    // Make NPCs not want to path through player
    // But don't make player pathing stop working
    for( const auto &p : pre_closed ) {
        if( p.x >= minx && p.x < maxx && p.y >= miny && p.y < maxy ) {
            pf.close_point( p );
        }
    }

    // Start and end must not be closed
    pf.unclose_point( f );
    pf.unclose_point( t );
    pf.add_point( 0, 0, f, f );

    bool done = false;

    do {
        auto cur = pf.get_next();

        const int parent_index = flat_index( cur.x, cur.y );
        auto &layer = pf.get_layer( cur.z );
        auto &cur_state = layer.state[parent_index];
        if( cur_state == ASL_CLOSED ) {
            continue;
        }

        if( layer.gscore[parent_index] > max_length ) {
            // Shortest path would be too long, return empty vector
            return std::vector<tripoint>();
        }

        if( cur == t ) {
            done = true;
            break;
        }

        cur_state = ASL_CLOSED;

        const auto &pf_cache = get_pathfinding_cache_ref( cur.z );
        const auto cur_special = pf_cache.special[cur.x][cur.y];

        // 7 3 5
        // 1 . 2
        // 6 4 8
//.........这里部分代码省略.........
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:101,代码来源:pathfinding.cpp


示例18: main

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QCommandLineParser parser;
    parser.addPositionalArgument(QStringLiteral("WId"),
                                 QStringLiteral("window id for the window to take the icon from"),
                                 QStringLiteral("[WId]"));
    parser.addHelpOption();
    parser.process(app);

    QWidget window;
    QVBoxLayout *vbox = new QVBoxLayout(&window);

    bool ok = false;
    qulonglong id = parser.positionalArguments().first().toULongLong(&ok);
    if (!ok) {
        // try hex
        id = parser.positionalArguments().first().toULongLong(&ok, 16);
    }
    if (!ok) {
        return 1;
    }
    NETWinInfo info(QX11Info::connection(), id, QX11Info::appRootWindow(), NET::WMIcon, NET::WM2WindowClass | NET::WM2IconPixmap);
    auto addIcons = [&window, vbox, &id, &info] (const QString &name, int flag) {
        QLabel *title = new QLabel(name, &window);
        vbox->addWidget(title);
        QIcon icons;
        if (flag & KWindowSystem::NETWM) {
            const int *iconSizes = info.iconSizes();
            int index = 0;
            while (iconSizes[index] != 0 && iconSizes[index + 1] != 0) {
                const int width = iconSizes[index++];
                const int height = iconSizes[index++];
                NETIcon ni = info.icon(width, height);
                if (ni.data) {
                    QImage img((uchar *) ni.data, (int) ni.size.width, (int) ni.size.height, QImage::Format_ARGB32);
                    if (!img.isNull()) {
                        icons.addPixmap(QPixmap::fromImage(img));
                    }
                }
            }
        }

        if (flag & KWindowSystem::WMHints) {
            icons.addPixmap(KWindowSystem::icon(id, 0, 0, false, KWindowSystem::WMHints, &info));
        }

        if (flag & KWindowSystem::ClassHint) {
            icons = QIcon::fromTheme(QString::fromUtf8(info.windowClassClass()).toLower());
        }
        if (flag & KWindowSystem::XApp) {
            icons = QIcon::fromTheme(QLatin1String("xorg"));
        }
        if (icons.isNull()) {
            return;
        }
        QHBoxLayout *layout = new QHBoxLayout();
        const auto sizes = icons.availableSizes();
        for (auto it = sizes.begin(); it != sizes.end(); ++it) {
            const QSize &s = *it;
            QVBoxLayout *v = new QVBoxLayout();
            QLabel *l = new QLabel(QStringLiteral("%1/%2").arg(s.width()).arg(s.height()), &window);
            v->addWidget(l);
            QLabel *p = new QLabel(&window);
            p->setPixmap(icons.pixmap(s));
            v->addWidget(p);
            layout->addLayout(v);
        }
        vbox->addLayout(layout);
    };
    addIcons(QStringLiteral("NetWM"), KWindowSystem::NETWM);
    addIcons(QStringLiteral("WMHints"), KWindowSystem::WMHints);
    addIcons(QStringLiteral("ClassHint"), KWindowSystem::ClassHint);
    addIcons(QStringLiteral("XApp"), KWindowSystem::XApp);

    window.setLayout(vbox);
    window.show();

    return app.exec();
}
开发者ID:KDE,项目名称:kwindowsystem,代码行数:80,代码来源:icontest.cpp


示例19: Q_ASSERT

// Destroy a universal proxy.
PyQtProxy::~PyQtProxy()
{
    Q_ASSERT((proxy_flags & PROXY_SLOT_INVOKED) == 0);

    if (hashed)
    {
        mutex->lock();

        switch (type)
        {
        case ProxySlot:
            {
                ProxyHash::iterator it(proxy_slots.find(saved_key));
                ProxyHash::iterator end(proxy_slots.end());

                while (it != end && it.key() == saved_key)
                {
                    if (it.value() == this)
                        it = proxy_slots.erase(it);
                    else
                        ++it;
                }

                break;
            }

        case ProxySignal:
            {
                ProxyHash::iterator it(proxy_signals.find(saved_key));
                ProxyHash::iterator end(proxy_signals.end());

                while (it != end && it.key() == saved_key)
                {
                    if (it.value() == this)
                        it = proxy_signals.erase(it);
                    else
                        ++it;
                }

                break;
            }
        }

        mutex->unlock();
    }

    if (type == ProxySlot && real_slot.signature)
    {
        // Qt can still be tidying up after Python has gone so make sure that
        // it hasn't.
        if (Py_IsInitialized())
        {
            SIP_BLOCK_THREADS
            sipFreeSipslot(&real_slot.sip_slot);
            SIP_UNBLOCK_THREADS
        }

        if (proxy_flags & PROXY_OWNS_SLOT_SIG)
            delete real_slot.signature;

        real_slot.signature = 0;
    }

    if (meta_object)
    {
#if QT_VERSION >= 0x050000
        free(const_cast<QMetaObject *>(meta_object));
#else
        if (meta_object != &staticMetaObject)
        {
            // The casts are needed for MSVC 6.
            delete[] const_cast<char *>(meta_object->d.stringdata);
            delete[] const_cast<uint *>(meta_object->d.data);
            delete meta_object;
        }
#endif
    }
}
开发者ID:AlexDoul,项目名称:PyQt4,代码行数:79,代码来源:qpycore_pyqtproxy.cpp


示例20: NegateFace

void NegateFace(Face & f)
{
    f.plane() = -f.plane();
    std::reverse(begin(f.vertex), end(f.vertex));
}
开发者ID:nikolobin,项目名称:sandbox,代码行数:5,代码来源:bsp.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ endCommand函数代码示例发布时间:2022-05-30
下一篇:
C++ encryptionStatusChanged函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap