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(); }
void ChunkManager::dataChecked(const BitSet & ok_chunks) { // go over all chunks at check each of them for (Uint32 i = 0;i < chunks.count();i++) { Chunk* c = chunks[i]; if (ok_chunks.get(i) && !bitset.get(i)) { // We think we do not hae a chunk, but we do have it bitset.set(i,true); todo.set(i,false); // the chunk must be on disk c->setStatus(Chunk::ON_DISK); tor.updateFilePercentage(i,bitset); } else if (!ok_chunks.get(i) && bitset.get(i)) { Out(SYS_DIO|LOG_IMPORTANT) << "Previously OK chunk " << i << " is corrupt !!!!!" << endl; // We think we have a chunk, but we don't bitset.set(i,false); todo.set(i,!only_seed_chunks.get(i) && !excluded_chunks.get(i)); if (c->getStatus() == Chunk::ON_DISK) { c->setStatus(Chunk::NOT_DOWNLOADED); tor.updateFilePercentage(i,bitset); } else if (c->getStatus() == Chunk::MMAPPED || c->getStatus() == Chunk::BUFFERED) { resetChunk(i); } else { tor.updateFilePercentage(i,bitset); } } } recalc_chunks_left = true; try { saveIndexFile(); } catch (bt::Error & err) { Out(SYS_DIO|LOG_DEBUG) << "Failed to save index file : " << err.toString() << endl; } catch (...) { Out(SYS_DIO|LOG_DEBUG) << "Failed to save index file : unkown exception" << endl; } chunksLeft(); corrupted_count = 0; }
/** * helper - add the users of the Defs of a given * instruction to the passed worklist. * * This encapsulates several nontrivial pieces of logic: * 1. Skip use instructions that haven't been reached yet. * 2. Skip over dead arms of constant conditionals. * 3. Jump the call-site gap between block delims. * (goto -> label, cond -> arm) * 4. When reaching a block the first time, mark all its instructions reached * *and* enque them, because they could have been previously skipped. */ void SCCP::addInstrUsers(Instr* instr) { for (AllUsesRange u(instr); !u.empty(); u.popFront()) { Instr* use_instr = user(u.front()); if (mark.get(use_instr->id)) ssawork.add(use_instr); } }
void ChunkCounter::decBitSet(const BitSet & bs) { for (Uint32 i = 0;i < cnt.size();i++) { if(bs.get(i)) dec(i); } }
void ChunkCounter::incBitSet(const BitSet & bs) { for (Uint32 i = 0;i < cnt.size();i++) { if(bs.get(i)) cnt[i]++; } }
BitSet BitSet::operator+(const BitSet& that) { BitSet result(*this); for (int i = 0; i < that.length(); ++i) { result.add(that.get(i)); } return result; }
void BitSet::orBitSet(const BitSet & other) { Uint32 i = 0; while (i < num_bits) { bool val = get(i) || other.get(i); set(i,val); i++; } }
void add(T item) { if (members.get(item->id)) return; Seq<T>* n = newnode(item); n->tail = 0; if (end) end->tail = n; else work = n; end = n; }
void PVCopy::updateCopyFromBitSet( PVStructure ©PVStructure,BitSet &bitSet,bool lockRecord) { bool doAll = bitSet.get(0); if(lockRecord) pvRecord.lock(); try { if(headNode->isStructure) { StructureNode *node = static_cast<StructureNode*>(headNode); updateStructureNodeFromBitSet( copyPVStructure,*node,bitSet,true,doAll); } else { RecordNode *node = static_cast<RecordNode*>(headNode); updateSubFieldFromBitSet( copyPVStructure,node->recordPVField,bitSet, true,doAll); } if(lockRecord) pvRecord.unlock(); } catch(...) { if(lockRecord) pvRecord.unlock(); throw; } }
void CLuceneIndexWriter::deleteEntry(const string& entry, lucene::index::IndexReader* reader) { int deleted = 0; wstring path(utf8toucs2(entry)); { Term t(systemlocation(), path.c_str()); deleted += reader->deleteDocuments(&t); // if no file was deleted, no more can be deleted if (deleted == 0) return; } { Term t(parentlocation(), path.c_str()); deleted += reader->deleteDocuments(&t); // if we have only deleted one file up to now, we cannot delete more if (deleted < 2) return; } { // delete all deeper nested files wstring v = utf8toucs2(entry+"/"); Term* t = _CLNEW Term(parentlocation(), v.c_str()); PrefixFilter* filter = _CLNEW PrefixFilter(t); BitSet* b = filter->bits(reader); _CLDELETE(filter); _CLDECDELETE(t); int32_t size = b->size(); for (int id = 0; id < size; ++id) { if (b->get(id) && !reader->isDeleted(id)) { reader->deleteDocument(id); deleted++; } } _CLDELETE(b); } }
/** * Enque the block. If it is already visited, just enqueu it. * Otherwise, mark it reached and enque all the instructions in the block. */ void SCCP::addBlock(BlockStartInstr* block) { if (!mark.get(block->id)) cfgwork.push(block); else ssawork.add(block); }