本文整理汇总了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);
}
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
}
}
示例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));
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
}
示例13: set_ctrl
inline void set_ctrl( bool _ctrl) { modifiers.set( ctrl, _ctrl); }
示例14: set_shift
inline void set_shift( bool _shift) { modifiers.set( shift, _shift); }
示例15: setDebugFlag
void setDebugFlag(DebugFlags _flag, bool _on) {
g_flags.set(_flag, _on);
m_view->setZoom(m_view->getZoom()); // Force the view to refresh
}