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


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

本文整理汇总了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();

}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: getAlts

BitSet ATNConfigSet::getAlts() {
  BitSet alts;
  for (ATNConfig config : configs) {
    alts.set(config.alt);
  }
  return alts;
}
开发者ID:RainerBosch,项目名称:antlr4,代码行数:7,代码来源:ATNConfigSet.cpp

示例3: initCopy

void PVCopy::initCopy(
    PVStructure &copyPVStructure, BitSet &bitSet, bool lockRecord)
{
    bitSet.clear();
    bitSet.set(0);
    updateCopyFromBitSet(copyPVStructure,bitSet,lockRecord);
}
开发者ID:epics-base,项目名称:pvIOCCPP,代码行数:7,代码来源:pvCopy.cpp

示例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;
}
开发者ID:Afreeca,项目名称:qt,代码行数:31,代码来源:ChainedFilter.cpp

示例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;
}
开发者ID:jeffreyadams,项目名称:atlasofliegroups,代码行数:9,代码来源:bitvector.cpp

示例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;
}
开发者ID:codedhead,项目名称:lex,代码行数:55,代码来源:NFA.cpp

示例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);
	}
}
开发者ID:codedhead,项目名称:lex,代码行数:12,代码来源:DFA.cpp

示例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;
 }
开发者ID:zhuzhonghua,项目名称:flash,代码行数:11,代码来源:hm-typeinference.cpp

示例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;
}
开发者ID:AJ92,项目名称:EntityCore,代码行数:22,代码来源:TestBitSet.cpp

示例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));
}
开发者ID:zhuzhonghua,项目名称:flash,代码行数:13,代码来源:hm-typeinference.cpp

示例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);
    }
  }
开发者ID:RCambier,项目名称:EmbeddedAndVerification,代码行数:23,代码来源:RabinAcceptance.hpp

示例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());
    }
}
开发者ID:pheest,项目名称:exampleCPP,代码行数:75,代码来源:pvaClientTestPutGetMonitor.cpp

示例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) );
}
开发者ID:AJ92,项目名称:EntityCore,代码行数:6,代码来源:EntityList.cpp

示例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
}
开发者ID:msekoranja,项目名称:pvDataCPP,代码行数:63,代码来源:testBitSet.cpp


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