<commit_before>///
/// @file   PrimeSieve.cpp
/// @brief  The PrimeSieve class provides an easy API for prime
///         sieving (single-threaded).
///
/// Copyright (C) 2013 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#include <primesieve/soe/config.h>
#include <primesieve/soe/PrimeSieve.h>
#include <primesieve/soe/primesieve_error.h>
#include <primesieve/soe/PrimeSieveCallback.h>
#include <primesieve/soe/PrimeSieve-lock.h>
#include <primesieve/soe/PrimeFinder.h>
#include <primesieve/soe/PrimeGenerator.h>
#include <primesieve/soe/imath.h>

#include <stdint.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <algorithm>

using namespace soe;

const PrimeSieve::SmallPrime PrimeSieve::smallPrimes_[8] =
{
  { 2,  2, 0, "2" },
  { 3,  3, 0, "3" },
  { 5,  5, 0, "5" },
  { 3,  5, 1, "(3, 5)" },
  { 5,  7, 1, "(5, 7)" },
  { 5, 11, 2, "(5, 7, 11)" },
  { 5, 13, 3, "(5, 7, 11, 13)" },
  { 5, 17, 4, "(5, 7, 11, 13, 17)" }
};

PrimeSieve::PrimeSieve() :
  start_(0),
  stop_(0),
  counts_(7),
  flags_(COUNT_PRIMES),
  threadNum_(0),
  parent_(NULL)
{
  setSieveSize(config::SIEVESIZE);
  reset();
}

/// ParallelPrimeSieve creates one PrimeSieve
/// child object for each thread.
///
PrimeSieve::PrimeSieve(PrimeSieve& parent, int threadNum) :
  counts_(7),
  sieveSize_(parent.sieveSize_),
  flags_(parent.flags_),
  threadNum_(threadNum),
  parent_(&parent),
  callback_(parent.callback_),
  callback_tn_(parent.callback_tn_),
  psc_(parent.psc_),
  psc_tn_(parent.psc_tn_)
{ }

PrimeSieve::~PrimeSieve()
{ }

uint64_t    PrimeSieve::getStart()                  const { return start_; }
uint64_t    PrimeSieve::getStop()                   const { return stop_; }
uint64_t    PrimeSieve::getInterval()               const { return stop_ - start_; }
uint64_t    PrimeSieve::getPrimeCount()             const { return counts_[0]; }
uint64_t    PrimeSieve::getTwinCount()              const { return counts_[1]; }
uint64_t    PrimeSieve::getTripletCount()           const { return counts_[2]; }
uint64_t    PrimeSieve::getQuadrupletCount()        const { return counts_[3]; }
uint64_t    PrimeSieve::getQuintupletCount()        const { return counts_[4]; }
uint64_t    PrimeSieve::getSextupletCount()         const { return counts_[5]; }
uint64_t    PrimeSieve::getSeptupletCount()         const { return counts_[6]; }
uint64_t    PrimeSieve::getCount(int index)         const { return counts_.at(index); }
double      PrimeSieve::getStatus()                 const { return percent_; }
double      PrimeSieve::getSeconds()                const { return seconds_; }
int         PrimeSieve::getSieveSize()              const { return sieveSize_; }
int         PrimeSieve::getFlags()                  const { return (flags_ & ((1 << 20) - 1)); }
bool        PrimeSieve::isValidFlags(int flags)     const { return (flags >= 0 && flags < (1 << 20)); }
bool        PrimeSieve::isFlag(int flag)            const { return (flags_ & flag) == flag; }
bool        PrimeSieve::isFlag(int first, int last) const { return (flags_ & (last * 2 - first)) != 0; }
bool        PrimeSieve::isCount(int index)          const { return isFlag(COUNT_PRIMES << index); }
bool        PrimeSieve::isPrint(int index)          const { return isFlag(PRINT_PRIMES << index); }
bool        PrimeSieve::isCallback()                const { return isFlag(CALLBACK, CALLBACK_OBJ_TN); }
bool        PrimeSieve::isCount()                   const { return isFlag(COUNT_PRIMES, COUNT_SEPTUPLETS); }
bool        PrimeSieve::isPrint()                   const { return isFlag(PRINT_PRIMES, PRINT_SEPTUPLETS); }
bool        PrimeSieve::isStatus()                  const { return isFlag(PRINT_STATUS, CALCULATE_STATUS); }
bool        PrimeSieve::isParallelPrimeSieveChild() const { return parent_ != NULL; }
<commit_msg>Refactoring<commit_after>///
/// @file   PrimeSieve.cpp
/// @brief  The PrimeSieve class provides an easy API for prime
///         sieving (single-threaded).
///
/// Copyright (C) 2013 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#include <primesieve/soe/config.h>
#include <primesieve/soe/PrimeSieve.h>
#include <primesieve/soe/primesieve_error.h>
#include <primesieve/soe/PrimeSieveCallback.h>
#include <primesieve/soe/PrimeSieve-lock.h>
#include <primesieve/soe/PrimeFinder.h>
#include <primesieve/soe/PrimeGenerator.h>
#include <primesieve/soe/imath.h>

#include <stdint.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <algorithm>

using namespace soe;

const PrimeSieve::SmallPrime PrimeSieve::smallPrimes_[8] =
{
  { 2,  2, 0, "2" },
  { 3,  3, 0, "3" },
  { 5,  5, 0, "5" },
  { 3,  5, 1, "(3, 5)" },
  { 5,  7, 1, "(5, 7)" },
  { 5, 11, 2, "(5, 7, 11)" },
  { 5, 13, 3, "(5, 7, 11, 13)" },
  { 5, 17, 4, "(5, 7, 11, 13, 17)" }
};

PrimeSieve::PrimeSieve() :
  start_(0),
  stop_(0),
  counts_(7),
  flags_(COUNT_PRIMES),
  threadNum_(0),
  parent_(NULL)
{
  setSieveSize(config::SIEVESIZE);
  reset();
}

/// ParallelPrimeSieve creates one PrimeSieve
/// child object for each thread.
///
PrimeSieve::PrimeSieve(PrimeSieve& parent, int threadNum) :
  counts_(7),
  sieveSize_(parent.sieveSize_),
  flags_(parent.flags_),
  threadNum_(threadNum),
  parent_(&parent),
  callback_(parent.callback_),
  callback_tn_(parent.callback_tn_),
  psc_(parent.psc_),
  psc_tn_(parent.psc_tn_)
{ }

PrimeSieve::~PrimeSieve()
{ }

uint64_t PrimeSieve::getStart()                  const { return start_; }
uint64_t PrimeSieve::getStop()                   const { return stop_; }
uint64_t PrimeSieve::getInterval()               const { return stop_ - start_; }
uint64_t PrimeSieve::getPrimeCount()             const { return counts_[0]; }
uint64_t PrimeSieve::getTwinCount()              const { return counts_[1]; }
uint64_t PrimeSieve::getTripletCount()           const { return counts_[2]; }
uint64_t PrimeSieve::getQuadrupletCount()        const { return counts_[3]; }
uint64_t PrimeSieve::getQuintupletCount()        const { return counts_[4]; }
uint64_t PrimeSieve::getSextupletCount()         const { return counts_[5]; }
uint64_t PrimeSieve::getSeptupletCount()         const { return counts_[6]; }
uint64_t PrimeSieve::getCount(int index)         const { return counts_.at(index); }
double   PrimeSieve::getStatus()                 const { return percent_; }
double   PrimeSieve::getSeconds()                const { return seconds_; }
int      PrimeSieve::getSieveSize()              const { return sieveSize_; }
int      PrimeSieve::getFlags()                  const { return (flags_ & ((1 << 20) - 1)); }
bool     PrimeSieve::isValidFlags(int flags)     const { return (flags >= 0 && flags < (1 << 20)); }
bool     PrimeSieve::isFlag(int flag)            const { return (flags_ & flag) == flag; }
bool     PrimeSieve::isFlag(int first, int last) const { return (flags_ & (last * 2 - first)) != 0; }
bool     PrimeSieve::isCount(int index)          const { return isFlag(COUNT_PRIMES << index); }
bool     PrimeSieve::isPrint(int index)          const { return isFlag(PRINT_PRIMES << index); }
bool     PrimeSieve::isCallback()                const { return isFlag(CALLBACK, CALLBACK_OBJ_TN); }
bool     PrimeSieve::isCount()                   const { return isFlag(COUNT_PRIMES, COUNT_SEPTUPLETS); }
bool     PrimeSieve::isPrint()                   const { return isFlag(PRINT_PRIMES, PRINT_SEPTUPLETS); }
bool     PrimeSieve::isStatus()                  const { return isFlag(PRINT_STATUS, CALCULATE_STATUS); }
bool     PrimeSieve::isParallelPrimeSieveChild() const { return parent_ != NULL; }

{'fraction_non_alphanumeric': 0.1439109615633493, 'fraction_numerical': 0.026142099132910573, 'mean_word_length': 3.1237993596584843, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6054381', 'n_tokens_mistral': 2774, 'n_tokens_neox': 2597, 'n_words': 600}