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); } } }
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(); }
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); } }
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; }
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; }
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(); }
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); }
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); } } }
void CallbackTemplate(u64 userdata, s64 lateness) { static_assert(IDX < CB_IDS.size(), "IDX out of range"); s_callbacks_ran_flags.set(IDX); EXPECT_EQ(CB_IDS[IDX], userdata); if (s_expected_callback) // In SharedSlot, we don't care about this EXPECT_EQ(CB_IDS[IDX], s_expected_callback); EXPECT_EQ(s_lateness, lateness); }
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)); }
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; }
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); } } } }
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); } } }
inline void set_ctrl( bool _ctrl) { modifiers.set( ctrl, _ctrl); }
inline void set_shift( bool _shift) { modifiers.set( shift, _shift); }
void setDebugFlag(DebugFlags _flag, bool _on) { g_flags.set(_flag, _on); m_view->setZoom(m_view->getZoom()); // Force the view to refresh }
inline void set_command( bool _command) { modifiers.set( command, _command); }
bool set(std::bitset<N>& bset, uint32 pos) { bool old = bset.test(pos); bset.set(pos); return old; }
FF::SearchState FF::Graph::SearchForPatterns(Graph *other, int row, Pattern &pattern, std::list<Pattern> &patterns, std::list<Node*> &affectedNodes, std::bitset<MAX_NODES> &affectedNodesBitset) { // Fetch the current node Node *node = this->m_Nodes[row]; if (affectedNodesBitset[node->Position]) { return NONE; } // Only if the pattern key is of the node's type if (this->m_Matrix[row][this->m_MatrixLength - 1] >= pattern.RequirementsLength && pattern.Key == node->Type) { // Create storage for the found matches std::list<Node*> matches; int nonTraversableMatches = 0; // Iterate of the columns for the given row #pragma omp parallel for ordered schedule(dynamic) for (unsigned int i = 0 ; i < this->m_Nodes.size() ; ++i) { // Narrow our matches set by only adding matches that were not yet marked // as affected if (!affectedNodesBitset[this->m_Nodes[i]->Position]) { // If the matrix contains a connection at row,i if (this->m_Matrix[row][i] == 1) { // In case of a match if (pattern.Requirements & (1 << this->m_Nodes[i]->Type.GetId())) { matches.push_back(this->m_Nodes[i]); } // Nothing to do else { } } } else { ++nonTraversableMatches; } } int s = matches.size() + nonTraversableMatches; // If the row contains all required types if (s >= pattern.RequirementsLength && s > 0) { // Invalidate the pattern pattern.Key = NullNodeType(); ++this->m_PatternsMatched; // Mark the node as affected affectedNodesBitset.set(this->m_Nodes[row]->Position); // Insert the node into the affected nodes list affectedNodes.push_back(this->m_Nodes[row]); // Recursively search for more matches this->SearchInMatches(other, matches, patterns, affectedNodes, affectedNodesBitset); // Return searchstate return TRAVERSE; } // Row does not contain all required types, but is a leaf else if (s == 0 && pattern.RequirementsLength == 0) { // Invalidate the pattern pattern.Key = NullNodeType(); ++this->m_PatternsMatched; // Mark the node as affected affectedNodesBitset.set(this->m_Nodes[row]->Position); // Insert the node into the affected nodes list affectedNodes.push_back(this->m_Nodes[row]); // Return searchstate return LEAF; } } return NONE; }
inline void set_leftdown( bool _ld) { buttons.set( left, _ld); }
inline void set_drag( bool _drag) { eventtype.set( drag, _drag); }
inline void set_click( bool _click) { eventtype.set( click, _click); }
inline void set_release( bool _release) { eventtype.set( release, _release); }
inline void set_press( bool _press) { eventtype.set( press, _press); }
void SetAvailableState(EKnockBackAnimationState s, bool b) { x80_availableStates.set(size_t(s), b); }
Supported define(Node<F,FS>) ///< @internal set the flag for one Format in the typelist { flags_.set (typeID<F>()); return define(FS()); }
inline void set_rightdown( bool _rd) { buttons.set( right, _rd); }
inline void set_alt( bool _alt) { modifiers.set( alt, _alt); } // option on Mac keyboard
/* parse_seq_file: read in the sequence stream and set * the global BitTable variable accordingly. */ bool parse_seq_file (const char* fname) { FILE* infile; char c; unsigned long lineno = 1L; index_t index; unsigned long tokens_seen = 0L; if (NULL == (infile = fopen(fname, "r"))) { fprintf(stderr, "ERROR: Failed to open input file %s for reading: " "%s\n", fname, strerror(errno)); return false; } for (;;) { bool found_token = false; c = getc(infile); if (EOF == c) { if (ferror(infile)) { fprintf(stderr, "ERROR: Failed to read from file %s:" "%s\n", fname, strerror(errno)); return false; } break; } switch (c) { case '\n': lineno++; case ' ': case '\t': case '\r': /* ignored spaces */ break; case 'G': index <<= BITS_PER_TOKEN; index |= G; found_token = true; break; case 'A': index <<= BITS_PER_TOKEN; index |= A; found_token = true; break; case 'T': index <<= BITS_PER_TOKEN; index |= T; found_token = true; break; case 'C': index <<= BITS_PER_TOKEN; index |= C; found_token = true; break; default: fprintf(stderr, "ERROR: File %s: line %lu: " "Invalid character found: '%c' (0x%x)\n", fname, lineno, c, c); return false; break; } if (found_token) { if (tokens_seen < APPEARS_SEQSIZE) { tokens_seen++; } if (tokens_seen >= APPEARS_SEQSIZE) { /* register this subsequence combination */ unsigned long index_ulong = index.to_ulong(); DD("setting the %luth bit", index_ulong); BitTable.set(index_ulong, 1); } } } fclose(infile); return true; }
inline void set_middledown( bool _md) { buttons.set( middle, _md); }