本文整理汇总了C++中std::bitset::flip方法的典型用法代码示例。如果您正苦于以下问题:C++ bitset::flip方法的具体用法?C++ bitset::flip怎么用?C++ bitset::flip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::bitset
的用法示例。
在下文中一共展示了bitset::flip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _grayCode
void _grayCode(std::vector<int> &ret, std::bitset<32> &bits, int pos) {
if (pos == 0) {
ret.push_back(static_cast<int>(bits.to_ulong()));
return ;
}
_grayCode(ret, bits, n, pos - 1);
bits.flip(pos - 1);
_grayCode(ret, bits, n, pos - 1);
}
示例2: while
void Tarea3::on_pushButton_2_clicked()
{
QString hey=ui->lineEdit_2->text();
ifstream read2("bits");
string line2;
string numero;
if(read2.is_open())
{
while (getline (read2,line2,'$').good())
{
QString ind=QString::fromStdString(line2);
numero=ind.toStdString();
}
}
read2.close();
int indice=hey.toInt();
std::bitset<32> b(numero);
b.flip(indice-1);
string mystring = b.to_string<char,char_traits<char>,allocator<char> >();
QString show=QString::fromStdString(mystring);
ui->listWidget->addItem(show);
ofstream myfile2 ("bits",ios::out);
std::cout<<mystring<<endl;
myfile2<<mystring<<"$";
myfile2.close();
// in_use = in_use ^ 1<<toBit;
}
示例3: rebuild
void rebuild()
{
p.reset();
p.flip();
p[0] = p[1] = 1;
for ( size_t n=2; n < PRIMES; ++n )
if ( p[n] ) {
v.push_back(n);
for ( size_t m=n<<1; m < PRIMES; m += n )
p[m] = 0;
}
}
示例4: toggleDebugFlag
void toggleDebugFlag(DebugFlags _flag) {
g_flags.flip(_flag);
m_view->setZoom(m_view->getZoom()); // Force the view to refresh
// Rebuild tiles for debug modes that needs it
if (_flag == DebugFlags::proxy_colors
|| _flag == DebugFlags::tile_bounds
|| _flag == DebugFlags::tile_infos) {
if (m_tileManager) {
std::lock_guard<std::mutex> lock(m_tilesMutex);
m_tileManager->clearTileSets();
}
}
}
示例5: randomFlip
void BSO::randomFlip(std::bitset<chromoLength> ¶msBS, int type)
{
return; //no change
int pos = 0;
if(type == 0) //flip in all position
{
pos = rand()%chromoLength;
}
else if(type == 1) //flip im only
{
pos = rand()%imLength;
}
else if(type == 2) //flip pf only
{
pos = imLength + rand()%pfLength;
}
paramsBS = paramsBS.flip(pos);
}
示例6: generate_sieve
// For correctness check out:
// "A Linear Sieve Algorithm for Finding Prime Numbers"
void generate_sieve()
{
sieve.flip(); // all bits are 1 now
for (int i=2; i<n; ++i){
if (sieve[i]){
primes.push_back(i);
}
for (int k=0; k<(int)primes.size() && i*primes[k]<n; ++k){
// For debug purposes:
// std::cout<<"i="<<i<<", k="<<k<<", "<<i*primes[k]<<std::endl;
// We reset the bit of a composite number, until we find lowest
// prime that divides i.
sieve.reset(i*primes[k]);
if (i%primes[k] == 0){
break;
}
}
}
}
示例7: toggleDebugFlag
void toggleDebugFlag(DebugFlags _flag) {
g_flags.flip(_flag);
m_view->setZoom(m_view->getZoom()); // Force the view to refresh
}
示例8: chk
inline void chk(int t){
if(vis[t]&&!--cnt[W[t]]) --res;
else if(!vis[t]&&!cnt[W[t]]++) ++res;
vis.flip(t);
}