本文整理汇总了C++中BitSet::set方法的典型用法代码示例。如果您正苦于以下问题:C++ BitSet::set方法的具体用法?C++ BitSet::set怎么用?C++ BitSet::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitSet
的用法示例。
在下文中一共展示了BitSet::set方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(const int argc, const char** argv) {
BitSet<24, char> bitset;
bitset.set(14);
std::cout << bitset.get(14) << "\n";
bitset.debug_print();
const size_t test_indices[] = {
26, 155, 95, 9, 3, 183, 154, 130, 102, 103, 105, 19,
161, 190, 61, 162, 183, 11, 3, 88, 18, 155, 169, 73,
59, 58, 0, 105, 191, 140, 191, 91, 3, 4, 139, 176, 176,
180, 168, 16, 143, 96, 77, 38, 178, 189, 118, 109, 138,
69, 110, 102, 66, 85, 32, 190, 76, 66, 86, 40, 35, 104,
101, 89, 124, 27, 125, 46, 134, 96, 93, 161, 178, 83, 114,
128, 8, 55, 108, 167, 11, 184, 74, 164, 169, 101, 140, 31,
120, 167, 190, 85, 158, 118, 19, 63, 175, 155, 80, 58
};
for (const auto& test_idx: test_indices) {
bitset.set(test_idx);
bool ans = bitset.get(test_idx);
if (!ans) {
throw std::runtime_error("Failed test");
}
}
bitset.debug_print();
}
示例2: getAlts
BitSet ATNConfigSet::getAlts() {
BitSet alts;
for (ATNConfig config : configs) {
alts.set(config.alt);
}
return alts;
}
示例3: initCopy
void PVCopy::initCopy(
PVStructure ©PVStructure, BitSet &bitSet, bool lockRecord)
{
bitSet.clear();
bitSet.set(0);
updateCopyFromBitSet(copyPVStructure,bitSet,lockRecord);
}
示例4: bits
BitSet* ChainedFilter::bits( IndexReader* reader, int logic )
{
BitSet* bts = NULL;
Filter** filter = filters;
// see discussion at top of file
if( *filter ) {
BitSet* tmp = (*filter)->bits( reader );
if ( (*filter)->shouldDeleteBitSet(tmp) ) //if we are supposed to delete this BitSet, then
bts = tmp; //we can safely call it our own
else if ( tmp == NULL ){
int32_t len = reader->maxDoc();
bts = _CLNEW BitSet( len ); //bitset returned null, which means match _all_
for (int32_t i=0;i<len;i++ )
bts->set(i);
}else{
bts = tmp->clone(); //else it is probably cached, so we need to copy it before using it.
}
filter++;
}
else
bts = _CLNEW BitSet( reader->maxDoc() );
while( *filter ) {
doChain( bts, reader, logic, *filter );
filter++;
}
return bts;
}
示例5:
void BitVector<dim>::unslice(BitSet<dim> t,size_t new_size)
{
BitSet<dim> result;
for (typename BitSet<dim>::iterator it=t.begin(); it();
d_data>>=1,++it)
result.set(*it,d_data[0]);
d_data=result;
d_size=new_size;
}
示例6: cloneFrag
NFAFrag NFA::cloneFrag(const NFAFrag& frag)
{
list<NFAState*> workList;
BitSet visited;
workList.push_back(frag.start);
visited.set(frag.start->stateId);
map<NFAState*,NFAState*> old2new;
typedef map<NFAState*,NFAState*>::iterator Old2NewIter;
while(!workList.empty())
{
NFAState* cur_state=workList.front();workList.pop_front();
for(map<int,NFAState*>::iterator it=cur_state->cedges.begin();it!=cur_state->cedges.end();++it)
{
NFAState* nextstate=0;
Old2NewIter findit;
if((findit=old2new.find(it->second))==old2new.end())
{
old2new[it->second]=nextstate=newState();
}
else
nextstate=findit->second;
cur_state->cedges[it->first]=nextstate;
if(!visited[nextstate->stateId])
workList.push_back(nextstate);
}
for(NFAStateArrIter it=cur_state->eedges.begin();it!=cur_state->eedges.end();++it)
{
NFAState* nextstate=0;
Old2NewIter findit;
if((findit=old2new.find(*it))==old2new.end())
{
old2new[*it]=nextstate=newState();
}
else
nextstate=findit->second;
patch(cur_state,nextstate);
if(!visited[nextstate->stateId])
workList.push_back(nextstate);
}
}
NFAFrag ret(old2new[frag.start],old2new[frag.out]);
return ret;
}
示例7: quickEclosure
// only set epsilon bits
void quickEclosure(NFAState* start,DFAState* res,BitSet& visited)
{
if(visited[start->stateId]) return;
visited.set(start->stateId);
res->nfaBits.or(start->eBits);
for(NFAStateArrIter it=start->eedges.begin();it!=start->eedges.end();++it)
{
quickEclosure(*it,res,visited);
}
}
示例8: new
Seq<T> *newnode(T item) {
members.set(item->id);
Seq<T>* n = free;
if (n) {
free = n->tail;
n->head = item;
} else {
n = new (alloc) Seq<T> (item);
}
return n;
}
示例9: main
int main()
{
BitSet<8> a;
a.set(0);
a.set(1);
a.set(2);
BitSet<8> b;
b.set(3);
cout << a.intersects(b) << endl;
b.set(1);
cout << a.intersects(b) << endl;
a.set(451);
cout << a.size() << endl;
return 0;
}
示例10: analyzeBlock
void SCCP::analyzeBlock(BlockStartInstr* block) {
// mark each instruction in the block.
for (InstrRange i(block); !i.empty(); i.popFront())
mark.set(i.front()->id);
// evaluate each instruction and queue all reachable users.
for (InstrRange i(block); !i.empty(); i.popFront()) {
Instr* instr = i.front();
eval_counts[instr->id]++;
analyzer.computeTypes(instr);
addInstrUsers(instr);
}
analyzeBranch(ir->blockEnd(block));
}
示例11: move_acceptance_bits
/**
* Move the bits set in acc to the places specified by mapping.
*/
void move_acceptance_bits(BitSet& acc,
std::vector<unsigned int> mapping) {
int i=acc.nextSetBit(0);
while (i!=-1) {
unsigned int j=mapping[i];
// :: j is always <= i
if (j>(unsigned int)i) {
THROW_EXCEPTION(Exception, "Wrong mapping in move_acceptance_bits");
}
if (((unsigned int)i) == j) {
// do nothing
} else {
// move bit from i->j
acc.set(j);
acc.clear(i);
}
i=acc.nextSetBit(i+1);
}
}
示例12: exampleDouble
static void exampleDouble(PvaClientPtr const &pvaClient)
{
testDiag("== exampleDouble ==");
PvaClientChannelPtr pvaChannel;
try {
pvaChannel = pvaClient->createChannel("PVRdouble");
pvaChannel->connect(2.0);
testDiag("channel connected");
} catch (std::runtime_error e) {
testAbort("channel connection exception '%s'", e.what());
}
PvaClientPutPtr put;
PvaClientPutDataPtr putData;
try {
put = pvaChannel->createPut();
putData = put->getData();
testDiag("put connected");
if (!putData)
testAbort("NULL data pointer from putGet");
} catch (std::runtime_error e) {
testAbort("put connection exception '%s'", e.what());
}
PvaClientGetPtr get;
PvaClientGetDataPtr getData;
try {
get = pvaChannel->createGet();
getData = get->getData();
testDiag("get connected");
if (!getData)
testAbort("NULL data pointer from putGet");
} catch (std::runtime_error e) {
testAbort("get connection exception '%s'", e.what());
}
PvaClientMonitorRequesterPtr requester(new MyMonitor());
PvaClientMonitorPtr monitor;
expected.set(0); // structure definition
try {
monitor = pvaChannel->monitor(requester);
testDiag("monitor connected");
} catch (std::runtime_error e) {
testAbort("monitor connection exception '%s'", e.what());
}
epicsThreadSleep(0.1); // Allow connection monitor event to fire
expected.clear(); // FIXME: Magic numbers here...
expected.set(1); // value
expected.set(6); // timestamp
try {
for (int i=0; i<5; ++i) {
testDiag("= put %d =", i);
double out = i;
putData->putDouble(out);
put->put();
get->get();
double in = getData->getDouble();
testOk(in == out, "get value matches put");
}
PvaClientProcessPtr process = pvaChannel->createProcess();
process->connect();
testDiag("= process =");
expected.clear(1); // no value change
process->process();
} catch (std::runtime_error e) {
testAbort("exception '%s'", e.what());
}
}
示例13: filter
VectorIterator<Entity*, EntityControllerFilter> EntityList::filterByControllers(vector<size_t> controllerIds)
{
BitSet bitset;
for(unsigned int i{0}; i < controllerIds.size(); ++i) bitset.set(i, controllerIds[i]);
return filter( EntityControllerFilter(bitset) );
}
示例14: testSerialize
static void testSerialize()
{
testDiag("testSerialization");
#define TOFRO(BB, BES, LES) do{tofrostring(BB, BES, NELEMENTS(LES)-1, EPICS_ENDIAN_BIG); \
tofrostring(BB, LES, NELEMENTS(LES)-1, EPICS_ENDIAN_LITTLE);}while(0)
{
BitSet dut;
TOFRO(dut, "\x00",
"\x00"); // zero size
}
{
BitSet dut;
dut.set(0);
TOFRO(dut, "\x01\x01",
"\x01\x01");
}
{
BitSet dut;
dut.set(1);
TOFRO(dut, "\x01\x02",
"\x01\x02");
}
{
BitSet dut;
dut.set(8);
TOFRO(dut, "\x02\x00\x01",
"\x02\x00\x01"); // high 64-bit word always LSB
}
{
BitSet dut;
dut.set(55);
dut.set(1);
TOFRO(dut, "\x07\x02\x00\x00\x00\x00\x00\x80",
"\x07\x02\x00\x00\x00\x00\x00\x80");
}
{
BitSet dut;
dut.set(63);
dut.set(1);
TOFRO(dut, "\x08\x80\x00\x00\x00\x00\x00\x00\x02",
"\x08\x02\x00\x00\x00\x00\x00\x00\x80");
}
{
BitSet dut;
dut.set(64);
dut.set(63);
dut.set(8);
dut.set(1);
TOFRO(dut, "\x09\x80\x00\x00\x00\x00\x00\x01\x02\x01",
"\x09\x02\x01\x00\x00\x00\x00\x00\x80\x01");
}
{
BitSet dut;
dut.set(126);
dut.set(64);
dut.set(63);
dut.set(1);
TOFRO(dut, "\x10\x80\x00\x00\x00\x00\x00\x00\x02\x40\x00\x00\x00\x00\x00\x00\x01",
"\x10\x02\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x40");
}
#undef TOFRO
}