本文整理汇总了C++中IndexSet类的典型用法代码示例。如果您正苦于以下问题:C++ IndexSet类的具体用法?C++ IndexSet怎么用?C++ IndexSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IndexSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WrongArgument
void Thread::removeOperator(const Operator* op)
{
typedef std::set< std::vector<Input>::iterator > IndexSet;
if (op == 0)
throw WrongArgument("Operator must not be null.");
m_thread->removeOperator(op);
IndexSet toBeErased;
for(std::vector<Input>::iterator iter1 = m_inputSequence.begin();
iter1 != m_inputSequence.end();
++iter1)
{
if((*iter1).op() == op)
toBeErased.insert(iter1);
}
for(IndexSet::reverse_iterator iter2 = toBeErased.rbegin();
iter2 != toBeErased.rend();
++iter2)
{
m_inputSequence.erase(*iter2);
}
}
示例2: RangeRightBound
IndexSet * mailcore::RangeUnion(Range range1, Range range2)
{
if (!RangeHasIntersection(range1, range2)) {
IndexSet * result = IndexSet::indexSet();
result->addRange(range1);
result->addRange(range2);
return result;
}
else {
uint64_t left1;
uint64_t right1;
uint64_t left2;
uint64_t right2;
uint64_t resultLeft;
uint64_t resultRight;
left1 = range1.location;
right1 = RangeRightBound(range1);
left2 = range2.location;
right2 = RangeRightBound(range2);
resultLeft = MIN(left1, left2);
resultRight = MAX(right1, right2);
if (resultRight == UINT64_MAX) {
return IndexSet::indexSetWithRange(RangeMake(resultLeft, UINT64_MAX));
}
else {
return IndexSet::indexSetWithRange(RangeMake(resultLeft, resultRight - resultLeft));
}
}
}
示例3: are_holes_inside
static inline bool are_holes_inside(RingIterator first,
RingIterator beyond,
ExteriorRing const& exterior_ring,
IndexSet const& rings_with_turns)
{
int idx = 0;
for (RingIterator it = first; it != beyond; ++it, ++idx)
{
// check only rings whose index is not associated to any turn
if ( rings_with_turns.find(idx) == rings_with_turns.end()
&& !geometry::within(range::front(*it), exterior_ring) )
{
return false;
}
}
// for those rings that do not have any associated turns,
// check if they lie inside another ring
idx = 0;
for (RingIterator it1 = first; it1 != beyond; ++it1, ++idx)
{
if ( rings_with_turns.find(idx) == rings_with_turns.end() )
{
for (RingIterator it2 = first; it2 != beyond; ++it2)
{
if ( it1 != it2
&& geometry::within(range::front(*it1), *it2) )
{
return false;
}
}
}
}
return true;
}
示例4: remove
void IndexSet::remove(const IndexSet& s) {
if (this == &s) { clear(); return; }
if (s.card() == 0) return;
if (card() == 0) return;
for (long i = s.first(); i <= s.last(); i = s.next(i)) remove(i);
// NOTE: traversal order should not matter here
}
示例5:
inline
void
VectorDBase<T>::assignT(T v, const IndexSet& is)
{
for (typename IndexSet::Iter i = is.begin(); i != is.end(); ++i) {
start[i] = v;
}
}
示例6: isDup
bool isDup(const IndexSet& data, const BSONObj& key, RecordId loc) {
const IndexSet::const_iterator it = data.find(IndexKeyEntry(key, RecordId()));
if (it == data.end())
return false;
// Not a dup if the entry is for the same loc.
return it->loc != loc;
}
示例7: verifyPrimeSet
// Sanity-check: Check that prime-set is "valid", i.e. that it
// contains either all the special primes or none of them
bool Ctxt::verifyPrimeSet() const
{
IndexSet s = primeSet & context.specialPrimes; // special primes in primeSet
if (!empty(s) && s!=context.specialPrimes) return false;
s = primeSet / s; // ctxt primes in primeSet
return (s.isInterval() && s.first()<=1 && !empty(s));
}
示例8: readContextBinary
void readContextBinary(istream& str, FHEcontext& context)
{
assert(readEyeCatcher(str, BINIO_EYE_CONTEXT_BEGIN)==0);
// Get the standard deviation
context.stdev = read_raw_xdouble(str);
long sizeOfS = read_raw_int(str);
IndexSet s;
for(long tmp, i=0; i<sizeOfS; i++){
tmp = read_raw_int(str);
s.insert(tmp);
}
context.moduli.clear();
context.specialPrimes.clear();
context.ctxtPrimes.clear();
long nPrimes = read_raw_int(str);
for (long p,i=0; i<nPrimes; i++) {
p = read_raw_int(str);
context.moduli.push_back(Cmodulus(context.zMStar,p,0));
if (s.contains(i))
context.specialPrimes.insert(i); // special prime
else
context.ctxtPrimes.insert(i); // ciphertext prime
}
long nDigits = read_raw_int(str);
context.digits.resize(nDigits);
for(long i=0; i<(long)context.digits.size(); i++){
sizeOfS = read_raw_int(str);
for(long tmp, n=0; n<sizeOfS; n++){
tmp = read_raw_int(str);
context.digits[i].insert(tmp);
}
}
// Read in the partition of m into co-prime factors (if bootstrappable)
Vec<long> mv;
read_ntl_vec_long(str, mv);
long t = read_raw_int(str);
bool consFlag = read_raw_int(str);
if (mv.length()>0) {
context.makeBootstrappable(mv, t, consFlag);
}
assert(readEyeCatcher(str, BINIO_EYE_CONTEXT_END)==0);
}
示例9: retain
void IndexSet::retain(const IndexSet& s) {
if (this == &s) return;
if (s.card() == 0) { clear(); return; }
if (card() == 0) return;
for (long i = first(); i <= last(); i = next(i)) {
if (!s.contains(i)) remove(i);
}
}
示例10: isDup
bool isDup(const IndexSet& data, const BSONObj& key) {
IndexSet::const_iterator it = data.find(IndexKeyEntry(key, RecordId()));
if (it == data.end())
return false;
++it;
if (it == data.end())
return false;
return it->key.woCompare(key, BSONObj(), false) == 0;
}
示例11: assert
inline
void
VectorDBase<T>::assign(const VectorDBase<T>& v1, const IndexSet& is)
{
assert(v1.get_size() == is.get_size());
assert(get_size() == is.count());
T* i = start;
for (typename IndexSet::Iter i1 = is.begin(); i1 != is.end(); ++i1) {
*i = v1[i1]; ++i;
}
}
示例12: findBaseLevel
//! @brief How many levels in the "base-set" for that ciphertext
long Ctxt::findBaseLevel() const
{
IndexSet s;
findBaseSet(s);
if (context.containsSmallPrime()) {
if (s.contains(context.ctxtPrimes.first()))
return 2*card(s) -1; // 1st prime is half size
else
return 2*card(s);
}
else return card(s); // one prime per level
}
示例13: while
void
LocalViewSelection::replaceViews(IndexSet const & toBeReplaced)
{
IndexSet::const_iterator tbr = toBeReplaced.begin();
while (tbr != toBeReplaced.end()) {
available[*tbr] = false;
selected.erase(*tbr);
++tbr;
}
success = false;
performVS();
}
示例14: findBaseSet
// Find the IndexSet such that modDown to that set of primes makes the
// additive term due to rounding into the dominant noise term
void Ctxt::findBaseSet(IndexSet& s) const
{
if (getNoiseVar()<=0.0) { // an empty ciphertext
s = context.ctxtPrimes;
return;
}
assert(verifyPrimeSet());
bool halfSize = context.containsSmallPrime();
double curNoise = log(getNoiseVar())/2;
double firstNoise = context.logOfPrime(0);
double noiseThreshold = log(modSwitchAddedNoiseVar())*0.55;
// FIXME: The above should have been 0.5. Making it a bit more means
// that we will mod-switch a little less frequently, whether this is
// a good thing needs to be tested.
// remove special primes, if they are included in this->primeSet
s = getPrimeSet();
if (!s.disjointFrom(context.specialPrimes)) {
// scale down noise
curNoise -= context.logOfProduct(context.specialPrimes);
s.remove(context.specialPrimes);
}
/* We compare below to noiseThreshold+1 rather than to noiseThreshold
* to make sure that if you mod-switch down to c.findBaseSet() and
* then immediately call c.findBaseSet() again, it will not tell you
* to mod-switch further down. Note that mod-switching adds close to
* noiseThreshold to the scaled noise, so if the scaled noise was
* equal to noiseThreshold then after mod-switchign you would have
* roughly twice as much noise. Since we're mesuring the log, it means
* that you may have as much as noiseThreshold+log(2), which we round
* up to noiseThreshold+1 in the test below.
*/
if (curNoise<=noiseThreshold+1) return; // no need to mod down
// if the first prime in half size, begin by removing it
if (halfSize && s.contains(0)) {
curNoise -= firstNoise;
s.remove(0);
}
// while noise is larger than threshold, scale down by the next prime
while (curNoise>noiseThreshold && !empty(s)) {
curNoise -= context.logOfPrime(s.last());
s.remove(s.last());
}
// Add 1st prime if s is empty or if this does not increase noise too much
if (empty(s) || (!s.contains(0) && curNoise+firstNoise<=noiseThreshold)) {
s.insert(0);
curNoise += firstNoise;
}
if (curNoise>noiseThreshold && log_of_ratio()>-0.5)
cerr << "Ctxt::findBaseSet warning: already at lowest level\n";
}
示例15: add_liveout
//------------------------------add_liveout------------------------------------
// Add a live-out value to a given blocks live-out set. If it is new, then
// also add it to the delta set and stick the block on the worklist.
void PhaseLive::add_liveout( Block *p, uint r, VectorSet &first_pass ) {
IndexSet *live = &_live[p->_pre_order-1];
if( live->insert(r) ) { // If actually inserted...
// We extended the live-out set. See if the value is generated locally.
// If it is not, then we must extend the live-in set.
if( !_defs[p->_pre_order-1].member( r ) ) {
if( !_deltas[p->_pre_order-1] && // Not on worklist?
first_pass.test(p->_pre_order) )
_worklist->push(p); // Actually go on worklist if already 1st pass
getset(p)->insert(r);
}
}
}