本文整理汇总了C++中dynamic_bitset类的典型用法代码示例。如果您正苦于以下问题:C++ dynamic_bitset类的具体用法?C++ dynamic_bitset怎么用?C++ dynamic_bitset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dynamic_bitset类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: all_characters_connected
/// Check that any two present nodes are connected by a path of present nodes
bool all_characters_connected(const Tree& T,dynamic_bitset<> present,const vector<int>& _ignore) {
assert(present.size() == T.n_nodes());
//--------- set the ignored nodes to 'not present' -----------//
dynamic_bitset<> ignore(present.size());
for(int i=0;i<_ignore.size();i++) {
int n = _ignore[i];
present[n] = false;
ignore[n] = true;
}
//---------- for each internal node... -------------//
for(int n1=T.n_leaves(); n1<T.n_nodes(); n1++) {
if (present[n1] or ignore[n1]) continue;
//------- if it is '-' and not ignored ... -------//
vector<const_nodeview> neighbors;
append(T[n1].neighbors(),neighbors);
assert(neighbors.size() == 3);
//---- check the three attatched subtrees ... ----//
int total=0;
for(int i=0;i<neighbors.size();i++) {
dynamic_bitset<> group = T.partition(n1,neighbors[i]);
if (present.intersects(group))
total++;
}
//----- nodes should be present in only one. -----//
if (total > 1)
return false;
}
return true;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:36,代码来源:alignment-util.C
示例2: can_die_early
static
bool can_die_early(const NGHolder &g, const vector<StateInfo> &info,
const dynamic_bitset<> &s,
map<dynamic_bitset<>, u32> &visited, u32 age_limit) {
if (contains(visited, s) && visited[s] >= age_limit) {
/* we have already (or are in the process) of visiting here with a
* looser limit. */
return false;
}
visited[s] = age_limit;
if (s.none()) {
DEBUG_PRINTF("dead\n");
return true;
}
if (age_limit == 0) {
return false;
}
dynamic_bitset<> all_succ(s.size());
step(g, info, s, &all_succ);
all_succ.reset(NODE_START_DOTSTAR);
for (u32 i = 0; i < N_CHARS; i++) {
dynamic_bitset<> next = all_succ;
filter_by_reach(info, &next, CharReach(i));
if (can_die_early(g, info, next, visited, age_limit - 1)) {
return true;
}
}
return false;
}
开发者ID:starius,项目名称:hyperscan,代码行数:34,代码来源:ng_execute.cpp
示例3: connect_all_characters
void connect_all_characters(const Tree& T,dynamic_bitset<>& present)
{
assert(present.size() == T.n_nodes());
//---------- for each internal node... -------------//
for(int n1=T.n_leaves(); n1<T.n_nodes(); n1++)
{
if (present[n1]) continue;
//------- if it is '-' and not ignored ... -------//
vector<const_nodeview> neighbors;
append(T[n1].neighbors(),neighbors);
assert(neighbors.size() == 3);
//---- check the three attatched subtrees ... ----//
int total=0;
for(int i=0;i<neighbors.size();i++)
{
dynamic_bitset<> group = T.partition(n1,neighbors[i]);
if (present.intersects(group))
total++;
}
if (total > 1)
present[n1] = true;
}
assert(all_characters_connected(T,present,vector<int>()));
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:28,代码来源:alignment-util.C
示例4: print
void print(const dynamic_bitset<>& items, ostream& out) {
out << "{ ";
for(dynamic_bitset<>::size_type i = items.find_first(); i != items.npos; i = items.find_next(i)){
out << i << " ";
}
out << "} -- " << items.count() << endl;
}
开发者ID:rvimieiro,项目名称:disjunctive_itemsets,代码行数:7,代码来源:Database.cpp
示例5: findFirstOf
uint32_t cFixedAlloc::findFirstOf(bool check, dynamic_bitset<>& bit) {
for ( int i = 0; i < bit.size(); ++i ) {
if ( bit[i] == check ) return i;
}
return bit.size() + 1;
}
开发者ID:ZuluForce,项目名称:5103-OS,代码行数:7,代码来源:frameAlloc.cpp
示例6: assert
Partition::Partition(const vector<string>& n,const dynamic_bitset<>& g,const dynamic_bitset<>& mask)
:names(n),group1((~ g) & mask),group2(g & mask)
{
assert(n.size() == g.size());
assert(g.size() == mask.size());
assert(not group1.intersects(group2));
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:7,代码来源:partition.C
示例7: diffset_for_single_item
vector<int> diffset_for_single_item(dynamic_bitset<> tids) {
vector<int> diffset;
dynamic_bitset<>::size_type size = tids.size();
for (dynamic_bitset<>::size_type i = 0; i < size; ++i)
if ( ! tids.test(i))
diffset.push_back(i);
return diffset;
}
开发者ID:lfritz,项目名称:data-mining-and-analysis,代码行数:8,代码来源:itemsets.cpp
示例8: dumpStates
static
std::string dumpStates(const dynamic_bitset<> &s) {
std::ostringstream oss;
for (size_t i = s.find_first(); i != s.npos; i = s.find_next(i)) {
oss << i << " ";
}
return oss.str();
}
开发者ID:starius,项目名称:hyperscan,代码行数:8,代码来源:ng_execute.cpp
示例9: getVertices
static
flat_set<NFAVertex> getVertices(const dynamic_bitset<> &in,
const vector<StateInfo> &info) {
flat_set<NFAVertex> out;
for (size_t i = in.find_first(); i != in.npos; i = in.find_next(i)) {
out.insert(info[i].vertex);
}
return out;
}
开发者ID:starius,项目名称:hyperscan,代码行数:9,代码来源:ng_execute.cpp
示例10: step
static
void step(const NGHolder &g, const vector<StateInfo> &info,
const dynamic_bitset<> &in, dynamic_bitset<> *out) {
out->reset();
for (size_t i = in.find_first(); i != in.npos; i = in.find_next(i)) {
NFAVertex u = info[i].vertex;
for (auto v : adjacent_vertices_range(u, g)) {
out->set(g[v].index);
}
}
}
开发者ID:starius,项目名称:hyperscan,代码行数:11,代码来源:ng_execute.cpp
示例11:
typename allocator<T>::dynamic_bitset allocator<T>::free_memory(const dynamic_bitset & memfree,
dynamic_bitset && mask)
{
assert(memfree.size() == mask.size());
assert(memfree.count() + mask.count() <= memfree.size());
auto res = memfree | mask;
# if DEBUG_SMA_TRACE_BITSET
std::cout << "a=memfree: " << memfree << std::endl;
std::cout << "b= mask: " << mask << std::endl;
std::cout << "r= a | b: " << res << std::endl;
# endif
assert(memfree.count() + mask.count() == res.count());
return res;
}
开发者ID:Angel707,项目名称:cpp11-snippets,代码行数:14,代码来源:allocator_impl.hpp
示例12: assert
bool
compare_complete_partitions::operator()(const dynamic_bitset<>& p1,
const dynamic_bitset<>& p2) const
{
assert(p1.size() == p2.size());
for(int i=0;i<p1.size();i++) {
if (p2[i] and not p1[i])
return true;
if (p1[i] and not p2[i])
return false;
}
return false;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:14,代码来源:tree-util.C
示例13: use
/// \brief Marks the specified arc as being used.
void use(const Tilewire& inTilewire1, const Tilewire& inTilewire2) {
// extract the tile indexes
TileIndex tileIndex1 = inTilewire1.getTileIndex();
TileIndex tileIndex2 = inTilewire2.getTileIndex();
// ensure that these tilewires belong to the same tile
/// \todo Throw a meaningful exception.
if(tileIndex1 != tileIndex2) throw InvalidArcException(Arc(inTilewire1, inTilewire2));
// make sure we have a bitset for this tile
dynamic_bitset* bitset = mBitsets[tileIndex1];
if(bitset == 0) {
// determine how many arcs are in this tile
const TileInfo& tileInfo = mTiles.getTileInfo(tileIndex1);
TileTypeIndex type = tileInfo.getTypeIndex();
const Array<const WireInfo>& wires = mTiles.getWireInfo(type);
if(wires.getSize() == 0) return;
const WireInfo& wireInfo = mTiles.getWireInfo(type, WireIndex(wires.getSize() - 1));
// caution: we have to add the regular and irregular sink count from the last wire
size_t size = wireInfo.getArcOffset() + wireInfo.getSinks().getSize()
+ wireInfo.getIrregularSinks().getSize()
+ wireInfo.getRoutethroughSinks().getSize()
+ wireInfo.getTiedSinks().getSize();
bitset = mBitsets[tileIndex1] = new dynamic_bitset(size);
// track the statistics
mTileUsageCount++;
mBitCount += size;
}
// set the bit and mark the tile dirty
bitset->set(getArcOffset(inTilewire1, inTilewire2));
mTileDirty.set(tileIndex1, true);
}
开发者ID:eddiehung,项目名称:dox-torc,代码行数:33,代码来源:ArcUsage.hpp
示例14: A_constant
bool A_constant(alignment A1, alignment A2, const dynamic_bitset<>& ignore) {
assert(A1.n_sequences() == A2.n_sequences());
// equality holds if we have internal node sequences -- otherwise ignore is larger
assert(A1.n_sequences() <= ignore.size());
// convert to feature-number notation
ublas::matrix<int> M1 = M(A1);
ublas::matrix<int> M2 = M(A2);
// lookup and cache the column each feature is in
vector< vector< int> > column_indices = column_lookup(A2);
//----- Check that the sequence lengths match ------//
for(int i=0;i<M1.size2();i++) {
if (ignore[i]) continue;
if (A1.seqlength(i) != A2.seqlength(i))
return false;
}
//----- Check that each homology in A1 is in A2 -----//
for(int column=0; column<A1.length(); column++)
for(int s1=0; s1 < A1.n_sequences(); s1++) {
if (ignore[s1]) continue;
for(int s2=s1+1; s2 < A1.n_sequences(); s2++) {
if (ignore[s2]) continue;
if (not A_match(M1,column,s1,s2,M2,column_indices))
return false;
}
}
return true;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:34,代码来源:alignment-util.C
示例15: setBitstreamBits
void StreamGenerator::setBitstreamBits(dynamic_bitset<>& bitStream,
int num, size_t bitsetIndex, size_t numIndex) {
unsigned int size = sizeof (unsigned int)*8;
if (numIndex < size) {
if (bitsetIndex < bitStream.size()) {
bitStream[bitsetIndex] = (num >> numIndex) & 0x1;
setBitstreamBits(bitStream, num, bitsetIndex + 1, numIndex + 1);
}
}
开发者ID:himura88,项目名称:randomNFAGenerator,代码行数:11,代码来源:StreamGenerator.cpp
示例16: clear
/// \brief Marks all arcs as being unused, without releasing the bitset objects.
/// \details This capability allows the tracer to track the wires that it has visited while
/// processing a particular net, and then to start again from scratch without incurring
/// allocation and construction overheads.
void clear(void) {
// iterate over all of the tiles
size_t tileCount = mBitsets.getSize();
for(TileIndex i; i < tileCount; i++) {
// skip this tile if it isn't dirty
if(!mTileDirty[i]) continue;
// mark the tile clean
mTileDirty.reset(i);
// look up the bitset for this tile
dynamic_bitset* bitset = mBitsets[i];
// skip tiles without an associated bitset (should never happen for dirty tiles)
if(bitset == 0) continue;
// clear the entire bitset
bitset->reset();
}
}
开发者ID:eddiehung,项目名称:dox-torc,代码行数:20,代码来源:ArcUsage.hpp
示例17: release
/// \brief Marks the specified arc as being unused.
void release(const Tilewire& inTilewire1, const Tilewire& inTilewire2) {
// extract the tile indexes
TileIndex tileIndex1 = inTilewire1.getTileIndex();
TileIndex tileIndex2 = inTilewire2.getTileIndex();
// ensure that these tilewires belong to the same tile
/// \todo Throw a meaningful exception.
if(tileIndex1 != tileIndex2) throw -1;
// if there is no entry for the tile, the arc is already implicitly unused.
dynamic_bitset* bitset = mBitsets[tileIndex1];
if(bitset == 0) return;
// otherwise clear the bit and mark the tile dirty
bitset->set(getArcOffset(inTilewire1, inTilewire2), false);
mTileDirty.set(tileIndex1, true);
}
开发者ID:eddiehung,项目名称:dox-torc,代码行数:17,代码来源:ArcUsage.hpp
示例18: assert
Partition::Partition(const vector<string>& n,const dynamic_bitset<>& g)
:names(n),group1(g),group2(~g)
{
assert(n.size() == g.size());
assert(not group1.intersects(group2));
}
开发者ID:msuchard,项目名称:BAli-Phy,代码行数:6,代码来源:partition.C
示例19: autosize
// functions
/// \brief Size the wire usage according to the number of device tiles.
void autosize(void) {
// release any existing bitsets
for(TileCount i; i < mBitsets.getSize(); i++) {
if(mBitsets[i] != 0) { delete mBitsets[i]; mBitsets[i] = 0; }
mTileDirty.reset(i);
}
// resize for the new dimensions
TileCount tileCount = mTiles.getTileCount();
mBitsets.setSize(tileCount);
for(TileCount i; i < tileCount; i++) mBitsets[i] = 0;
mTileDirty.resize(tileCount);
}
开发者ID:eddiehung,项目名称:dox-torc,代码行数:14,代码来源:ArcUsage.hpp
注:本文中的dynamic_bitset类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论