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


C++ bitset::set方法代码示例

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


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

示例1: load

inline void load(
    Archive & ar,
    STD::bitset<Bits> &t,
    const unsigned int /* file_version */
){
    if (ar.get_flags() & boost::archive::packed_bools) {
        const unsigned Bytes = Bits / 8;
        for (unsigned int i = 0; i < Bytes; i++){
            unsigned char theByte;
            ar >> boost::serialization::make_nvp("item", theByte);
            const unsigned int count = 8 * i;
            t.set(count, theByte & 0x01);
            for (unsigned int j = 1; j < 8; j++) {
                theByte = theByte >> 1;
                t.set(count + j, theByte & 0x01);
            }
        }
        // handle any partial byte
        const unsigned extraBits = Bits - 8 * Bytes;
        if (extraBits > 0) {
            unsigned char theByte;
            ar >> boost::serialization::make_nvp("item", theByte);
            const unsigned int count = 8 * Bytes;
            t.set(count, theByte & 0x01);
            for (unsigned int j = 1; j < extraBits; j++) {
                theByte = theByte >> 1;
                t.set(count + j, theByte & 0x01);
            }
        }
    }
开发者ID:cce,项目名称:serialization,代码行数:30,代码来源:bitset.hpp

示例2: add_target

void OPKiller::add_target(int area, int opcode) {
    rwlock_.write_lock();
    areas_filter_.set(area & BLOOM_FILTER_MASK);
    opcodes_filter_.set(opcode & BLOOM_FILTER_MASK);
    target_areas_.insert(area);
    target_opcodes_.insert(opcode);
    enable();
    rwlock_.write_unlock();
}
开发者ID:alibaba,项目名称:tair,代码行数:9,代码来源:op_killer.hpp

示例3:

Board::Board()
{
	bitBoard.reset();
	winMask.set(1);
	winMask.set(9);
	winMask.set(11);
	winMask.set(19);

	for (int i = 1; i < BOARD_SIZE; i += 2)
	{
		endMask.set(i);
	}
}
开发者ID:SeamonkeyHasMyMoney,项目名称:KillTheTrolls,代码行数:13,代码来源:Board.cpp

示例4: choose_threads

void Sync::choose_threads(){
    int ref = -1;
    for (UINT ii=0; ii<num_threads; ii++){
        unsigned int i = (ii + rrcounter) % num_threads;
        if ( !t[i].ignore && !was_executed.test(i) ){
            ref = i;
            break;
        }
    }
    if (ref == -1){
        was_executed.reset();
        for (UINT ii=0; ii<num_threads; ii++){
            unsigned int i = (ii + rrcounter) % num_threads;
            if (!t[i].ignore){
                ref = i;
                break;
            }
        }
    }
    
    for (UINT i=0; i<num_threads; i++){
        t[i].is_active = !t[i].ignore && t[i].pc == t[ref].pc;
        if (t[i].is_active){
            was_executed.set(i);
        }
    }
    
    // Next
    rrcounter = (ref + 1) % num_threads;
}
开发者ID:dougct,项目名称:mmt-sync,代码行数:30,代码来源:RoundRobin_Eq.cpp

示例5: load_board

void load_board(void)
{
	int i, j;
	char ch;
	std::bitset< 16 > stat;
	std::string str_stat;
	for(i = 0; i < N; ++i)
	{
		for(j = 0; j <= N; ++j)
		{
			ch = getchar();
			if(ch != '\n')
				str_stat += ch;
			
		}
	}
	for(i = 0; i < str_stat.size(); ++i)
	{
		if(str_stat[i] == 'b')
			stat.set(i);
	}
	unsigned long s = stat.to_ulong();
	stat_queue.push(s);
	status_set.set(s);
	return;
}
开发者ID:jflyup,项目名称:POJ,代码行数:26,代码来源:poj1753.cpp

示例6: ReadConfig

	void ReadConfig(ConfigStatus& status) override
	{
		ConfigTag* tag = ServerInstance->Config->ConfValue("channames");
		std::string denyToken = tag->getString("denyrange");
		std::string allowToken = tag->getString("allowrange");

		if (!denyToken.compare(0, 2, "0-"))
			denyToken[0] = '1';
		if (!allowToken.compare(0, 2, "0-"))
			allowToken[0] = '1';

		allowedmap.set();

		irc::portparser denyrange(denyToken, false);
		int denyno = -1;
		while (0 != (denyno = denyrange.GetToken()))
			allowedmap[denyno & 0xFF] = false;

		irc::portparser allowrange(allowToken, false);
		int allowno = -1;
		while (0 != (allowno = allowrange.GetToken()))
			allowedmap[allowno & 0xFF] = true;

		allowedmap[0x07] = false; // BEL
		allowedmap[0x20] = false; // ' '
		allowedmap[0x2C] = false; // ','

		ValidateChans();
	}
开发者ID:Adam-,项目名称:inspircd,代码行数:29,代码来源:m_channames.cpp

示例7: enable_voltage_reading

void shrimp_gateway_impl::enable_voltage_reading() {

    //update_control_flags();
    m_control_flags.set(6);

    shrimp_command_t enable_voltage(CONTROL_FLAGS, write_t, static_cast <all::core::uint8_t> (m_control_flags.to_ulong()));
    send_command(enable_voltage);
}
开发者ID:chenbk85,项目名称:alcordev,代码行数:8,代码来源:shrimp_gateway_impl.cpp

示例8: init

  void init() {
    primes.set();
    // Sieve primes:
    for(int i = 0; i*i < PRIME_LEN; ++i) {
      if(!primes[i])
	continue;
      // Mark all uneven multiples as non-prime:
      int basePrime = 1+2*(i+1);
      for(int multiple = 3; true; multiple += 2) {
	int notAPrime = basePrime*multiple;
	int notAPrimeI = notAPrime/2-1;
	if(notAPrimeI >= PRIME_LEN)
	  break;
	primes.set(notAPrimeI, false);
      }
    }
  }
开发者ID:LasseD,项目名称:uva,代码行数:17,代码来源:P884.cpp

示例9: OnRehash

	void OnRehash(User*)
	{
		/* from m_sethost: use the same configured host character map if it exists */
		std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");

		hostmap.reset();
		for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
			hostmap.set(static_cast<unsigned char>(*n));
	}
开发者ID:aszrul,项目名称:inspircd-extras,代码行数:9,代码来源:m_conn_vhost.cpp

示例10: flip

int flip()
{
	int loop_count = 0;

	while(!stat_queue.empty())
	{
		loop_count++;
		unsigned long stat = stat_queue.front();
		stat_queue.pop();
		if(finished(stat))
		{
			int steps = 0;
			while(path[stat] != 0)
			{
				++steps;
				stat = path[stat];
			}
			printf("%d", steps);
			return 0;
		}
		int xPos, yPos;
		for(xPos = 0; xPos < N; ++xPos)
		{
			for(yPos = 0; yPos < N; ++yPos)
			{
				int i;
				std::bitset < 16 > next_stat(stat);
				for(i = 0; i < 5; ++i)
				{
					if(is_legal_position(xPos + move[i][0], yPos + move[i][1]) )
					{
						next_stat.flip((xPos + move[i][0]) * N + (yPos + move[i][1]) );
					}

				}

				//printf("%d\n", next_stat.to_ulong());
				unsigned long num_status = next_stat.to_ulong();
				if(!status_set.test(num_status))
				{
					status_set.set(num_status);
					//remember where current status comes from.
					path[num_status] = stat;
					stat_queue.push(num_status);
				}
			}
		}
	}
	printf("Impossible");
	return -1;
}
开发者ID:jflyup,项目名称:POJ,代码行数:51,代码来源:poj1753.cpp

示例11: RunAnimation

void RunAnimation(int speed, string init, std::bitset<BITSETSIZE>& states)
{
    int chamber_length = init.size();
    auto data = init.data();
    int distance = 0;
    int steps = 0;
    //Initial states;
    for (int i=0; i<init.size(); ++i)
    {
	if (data[i]=='R' || data[i]=='L')
	{
	    states.set(i);
	}
    }

    for (int i=0; i<init.size(); ++i)
    {
	if (data[i]=='R')
	{
	    distance = chamber_length-1-i;
	    steps = distance / speed + 1;
	    for (int j=1; j<steps; ++j)
	    {
		states.set(j*chamber_length+i+j*speed);
	    }
	}
	else if (data[i]=='L')
	{
	    distance = i;
	    steps = distance / speed + 1;
	    for (int j=1; j<steps; ++j)
	    {
		states.set(j*chamber_length+i-j*speed);
	    }
	}

    }
}
开发者ID:zhongchen,项目名称:Programming,代码行数:38,代码来源:Animation.cpp

示例12: getAllOnlineState

void OnlineStateFilterAdapter::getAllOnlineState(std::bitset<ONLINESTATE_FILTER_SIZE>& s) {
	MyUtil::ByteSeq result;
	for (int i=0;i<210;i++) {
		MyUtil::ByteSeq temp = getProxy(0)->getOnlineStateMinMax(i*10000000, (i+1)*10000000);
		result.insert(result.end(), temp.begin(), temp.end());
	}
	MyUtil::ByteSeq temp=getProxy(0)->getOnlineStateMinMax(2100000000, 2147483647);
	result.insert(result.end(), temp.begin(), temp.end());
	for (int i=0;i<ONLINESTATE_FILTER_SIZE;++i) {
		if (result[i/8]&(1<<(i%8))) {
			s.set(i);
		}
	}
}
开发者ID:bradenwu,项目名称:oce,代码行数:14,代码来源:OnlineStateFilterAdapter.cpp

示例13: set_ctrl

	inline void set_ctrl( bool _ctrl) { modifiers.set( ctrl, _ctrl); }
开发者ID:Emma920,项目名称:visual,代码行数:1,代码来源:mouseobject.hpp

示例14: set_shift

	inline void set_shift( bool _shift) { modifiers.set( shift, _shift); }
开发者ID:Emma920,项目名称:visual,代码行数:1,代码来源:mouseobject.hpp

示例15: setDebugFlag

void setDebugFlag(DebugFlags _flag, bool _on) {

    g_flags.set(_flag, _on);
    m_view->setZoom(m_view->getZoom()); // Force the view to refresh

}
开发者ID:examyes,项目名称:tangram-es,代码行数:6,代码来源:tangram.cpp


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