本文整理汇总了C++中PrimeSieve::callbackPrimes方法的典型用法代码示例。如果您正苦于以下问题:C++ PrimeSieve::callbackPrimes方法的具体用法?C++ PrimeSieve::callbackPrimes怎么用?C++ PrimeSieve::callbackPrimes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrimeSieve
的用法示例。
在下文中一共展示了PrimeSieve::callbackPrimes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushBack_N_Primes
void pushBack_N_Primes(uint64_t n, uint64_t start)
{
n_ = n;
PrimeSieve ps;
std::size_t newSize = primes_.size() + static_cast<std::size_t>(n_);
primes_.reserve(newSize);
try
{
while (n_ > 0)
{
// choose stop > nth prime
uint64_t logx = 50;
uint64_t dist = n_ * logx + 10000;
uint64_t stop = start + dist;
// fix integer overflow
if (stop < start)
stop = get_max_stop();
ps.callbackPrimes(start, stop, this);
start = stop + 1;
if (stop >= get_max_stop())
throw primesieve_error("cannot generate primes > 2^64");
}
}
catch (cancel_callback&) { }
}
示例2: pushBackPrimes
void pushBackPrimes(uint64_t start, uint64_t stop)
{
if (start <= stop)
{
std::size_t prime_count = approximate_prime_count(start, stop);
primes_.reserve(primes_.size() + prime_count);
PrimeSieve ps;
ps.callbackPrimes(start, stop, this);
}
}
示例3: pushBack_N_Primes
void pushBack_N_Primes(uint64_t n, uint64_t start)
{
n_ = n;
std::size_t newSize = primes_.size() + static_cast<std::size_t>(n_);
primes_.reserve(newSize);
PrimeSieve ps;
try
{
while (n_ > 0)
{
uint64_t logn = 50;
// choose stop > nth prime
uint64_t stop = start + n_ * logn + 10000;
ps.callbackPrimes(start, stop, this);
start = stop + 1;
}
}
catch (cancel_callback&) { }
}
示例4: callback_primes
void callback_primes(uint64_t start, uint64_t stop, Callback<uint64_t>* callback)
{
PrimeSieve ps;
ps.setSieveSize(get_sieve_size());
ps.callbackPrimes(start, stop, callback);
}