本文整理汇总了C++中set::cbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ set::cbegin方法的具体用法?C++ set::cbegin怎么用?C++ set::cbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set
的用法示例。
在下文中一共展示了set::cbegin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void EulerUtils::Display::printSet ( string itemName, const set<unsigned long long>& data ) {
cout << endl << "Printing " << itemName << "..." << endl;
for ( auto i = data.cbegin(); i != data.cend(); i++ ) {
cout << ( i == data.cbegin() ? "" : ", " ) << *i ;
}
cout << endl;
}
示例2: runtime_error
/** Extract masked detectors from a MaskWorkspace
* @return vector of detector IDs of the detectors that are
* masked
*/
std::vector<detid_t> ExtractMaskToTable::extractMaskFromMaskWorkspace() {
// output vector
std::vector<detid_t> maskeddetids;
// Go through all spectra to find masked workspace
MaskWorkspace_const_sptr maskws =
boost::dynamic_pointer_cast<const MaskWorkspace>(m_dataWS);
size_t numhist = maskws->getNumberHistograms();
for (size_t i = 0; i < numhist; ++i) {
// Rule out the spectrum without mask
if (maskws->readY(i)[0] < 1.0E-9)
continue;
// Get spectrum
const API::ISpectrum *spec = maskws->getSpectrum(i);
if (!spec)
throw runtime_error(
"Unable to get spectrum reference from mask workspace.");
const set<detid_t> detidset = spec->getDetectorIDs();
std::copy(detidset.cbegin(), detidset.cend(),
std::inserter(maskeddetids, maskeddetids.end()));
}
return maskeddetids;
}
示例3: buildLexicon
void BogglePlayer::buildLexicon(const set<string>& word_list){
string newWord;
const int minimum_word_length = 3;
set<string>::iterator wordlistBegin = word_list.cbegin();
set<string>::iterator wordlistEnd = word_list.cend();
std::srand(unsigned(time(0)));
std::vector<string> vector;
for(; wordlistBegin != wordlistEnd; ++wordlistBegin)
{
vector.push_back(*wordlistBegin);
}
std::random_shuffle(vector.begin(), vector.end());
for(auto it = vector.begin(); it != vector.end(); ++it)
{
newWord.assign(*it);
if(newWord.length() >= minimum_word_length)
{
t->add(newWord);
}
}
BogglePlayer::buildLexiconFlag = true;
};
示例4: cleanSet
unsigned RelationManager::cleanSet(set<const Class *> &s)
{
unsigned deletedRecords = 0;
for (auto it = s.cbegin(); it != s.cend();) {
if ((*it) == nullptr) {
s.erase(it++); ++deletedRecords;
} else ++it;
}
return deletedRecords;
}
示例5: select
unsigned select(const vector<unsigned> &S, const set<unsigned> &Suni, const string &mode)
{
unsigned res;
auto Suni_it = Suni.cbegin();
if (mode == "uni")
{
advance(Suni_it, rand() % Suni.size());
res = *(Suni_it);
}
else if (mode == "pop")
res = *(S.cbegin() + rand() % S.size());
return res;
}
示例6: precomputeTransferPatterns
void Server::precomputeTransferPatterns() {
// ProfilerStart("log/tp.perf");
if (loadTransferPatternsDB(&_tpdb)) {
_log.info("Loaded transfer patterns.");
} else {
if (_tpdb.numGraphs() == 0) {
_tpdb.init(_network.numStops(), _router.hubs());
}
const int progId = _log.beginProg();
const size_t numStops = _network.numStops();
const int nThreads = _maxWorkers > omp_get_max_threads() ?
omp_get_max_threads() : _maxWorkers;
omp_set_num_threads(nThreads);
int progress = 0;
#pragma omp parallel
{ // NOLINT
const TransitNetwork network = _network;
const HubSet hubs = _router.hubs();
TPDB tpdb(network.numStops(), hubs);
#pragma omp for schedule(dynamic, 3)
for (size_t stop = 0; stop < numStops; ++stop) {
const set<vector<int> > patterns =
TransferPatternRouter::computeTransferPatterns(network, stop, hubs);
for (auto it = patterns.cbegin(), end = patterns.cend(); it != end; ++it)
tpdb.addPattern(*it);
tpdb.finalise(stop); // clears construction cache
#pragma omp critical(progress_message)
if (progress < 100 || progress % (numStops / 100) == 0)
_log.prog(progId, progress + 1, numStops,
"computing transfer patterns (mt)", omp_get_num_threads());
#pragma omp atomic
++progress;
}
#pragma omp critical(reduction)
{ // NOLINT
// combine and clear the local TPDB
_tpdb += tpdb;
tpdb = TransferPatternsDB();
}
} // pragma omp parallel
saveTransferPatternsDB(_tpdb);
}
_router.transferPatternsDB(_tpdb);
// ProfilerStop();
}
示例7: merge
static set<range> merge(const vector<range>& vr){
const set<range> sr(vr.cbegin(), vr.cend());
set<range> result;
// doAlgo(vr.cbegin(), vr.cend(), res);
if(sr.size() == 0){
return result;
}
auto iter = sr.cbegin();
range prev = *iter;
while(++iter != sr.cend()){
range curr = *iter;
if(prev.second < curr.first){
result.insert(prev);
prev = curr;
} else {
prev = range(prev.first, max(prev.second, curr.second));
}
}
result.insert(prev);
return result;
}
示例8:
set<M> operator+ (const set<M>& lhs, const set<M>& rhs){
set<M> U{lhs};
U.insert(rhs.cbegin(), rhs.cend());
return U;
}
示例9: main
//.........这里部分代码省略.........
cin >> ed;
if(ed == 'y' || ed == 'Y')main1->edit();
}
else cout << "\n\nNot found !!!!" << endl;
break;
case 'e':
//edit a specific partida
break;
case 's':
//we want to save th whole set, not only one object
file.open("prevision.bin",ios_base::out | ios_base::binary);
if(file.is_open())
{
number_partidas = cont_main2.size();
// static size_t number_projects=0;
// number_projects=project.size();
//the first byte in disk will be the number of objects/partidas.. next the objects
file.write(reinterpret_cast<const char*>(&(number_partidas)),sizeof(number_partidas));
//the second byte will contain the number of projectd
// file.write(reinterpret_cast<const char*>(&(number_projects)),sizeof(number_projects));
p=cont_main2.cbegin();//point to the begining of the vector (dinamic array)
main2=*p;
main1=&main2;
// main1 -> saveMonths();
for(size_t x = 0 ; x < number_partidas ; ++x)
{
main2 = *p;
main1 -> save_file();//p contains an object a partida...saves ONE object/partida
++p;//next object ... next partida
}
}
file.close();
cout << "\n*** FILE SAVED ***\n";
break;
case 'l':
file.open("prevision.bin",ios_base::in | ios_base::binary);
if(file.is_open())
{
cont_main2.erase(cont_main2.begin(),cont_main2.end());
int numberPartidas;//we read the number of objects/partidas
file.read((char*)&numberPartidas,sizeof(numberPartidas) );
for(int x = 0;x < numberPartidas; ++x)
main1 -> load_partida();
project.push_back(cont_main2);