本文整理汇总了C++中set::cend方法的典型用法代码示例。如果您正苦于以下问题:C++ set::cend方法的具体用法?C++ set::cend怎么用?C++ set::cend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set
的用法示例。
在下文中一共展示了set::cend方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activate
/**
* Searches certificate by subject and returns a copy of it if found.
* If not found returns <code>NULL</code>.
* NB! The returned certificate must be freed with OpenSSL function X509_free(X509* cert).
*
* @param subject certificate subject.
* @return returns copy of found certificate or <code>NULL</code> if certificate was not found.
* @throws IOException exception is thrown if copying certificate failed.
*/
X509Cert X509CertStore::findIssuer(const X509Cert &cert, const set<string> &type) const
{
activate(cert.issuerName("C"));
SCOPE(AUTHORITY_KEYID, akid, X509_get_ext_d2i(cert.handle(), NID_authority_key_identifier, nullptr, nullptr));
for(const TSL::Service &s: *d)
{
if(type.find(s.type) == type.cend())
continue;
for(const X509Cert &i: s.certs)
{
if(!akid || !akid->keyid)
{
if(X509_NAME_cmp(X509_get_subject_name(i.handle()), X509_get_issuer_name(cert.handle())))
return i;
}
else
{
SCOPE(ASN1_OCTET_STRING, skid, X509_get_ext_d2i(i.handle(), NID_subject_key_identifier, nullptr, nullptr));
if(skid.get() && ASN1_OCTET_STRING_cmp(akid->keyid, skid.get()) == 0)
return i;
}
}
}
return X509Cert();
}
示例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:
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;
}
示例4: 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;
};
示例5:
/**
* Return STACK_OF(X509) containing all certs loaded from directory
* @return STACK_OF(X509) all certs in store.
* throws IOException
*/
vector<X509Cert> X509CertStore::certs(const set<string> &type) const
{
vector<X509Cert> certs;
for(const TSL::Service &s: *d)
{
if(type.find(s.type) != type.cend())
certs.insert(certs.end(), s.certs.cbegin(), s.certs.cend());
}
return certs;
}
示例6: switch
int X509CertStore::validate(int ok, X509_STORE_CTX *ctx, const set<string> &type)
{
switch(X509_STORE_CTX_get_error(ctx))
{
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
case X509_V_ERR_CERT_UNTRUSTED:
{
X509 *x509 = X509_STORE_CTX_get0_cert(ctx);
SCOPE(AUTHORITY_KEYID, akid, X509_get_ext_d2i(x509, NID_authority_key_identifier, nullptr, nullptr));
for(const TSL::Service &s: *instance()->d)
{
if(type.find(s.type) == type.cend())
continue;
auto certFound = find_if(s.certs.cbegin(), s.certs.cend(), [&](const X509Cert &issuer){
if(X509_cmp(x509, issuer.handle()) == 0)
return true;
if(!akid || !akid->keyid)
{
if(X509_NAME_cmp(X509_get_subject_name(issuer.handle()), X509_get_issuer_name(x509)) != 0)
return false;
}
else
{
SCOPE(ASN1_OCTET_STRING, skid, X509_get_ext_d2i(issuer.handle(), NID_subject_key_identifier, nullptr, nullptr));
if(!skid.get() || ASN1_OCTET_STRING_cmp(akid->keyid, skid.get()) != 0)
return false;
}
SCOPE(EVP_PKEY, pub, X509_get_pubkey(issuer.handle()));
if(X509_verify(x509, pub.get()) == 1)
return true;
OpenSSLException(); //Clear errors
return false;
});
if(certFound == s.certs.cend())
continue;
X509_STORE_CTX_set_ex_data(ctx, 0, const_cast<TSL::Validity*>(&s.validity[0]));
X509_VERIFY_PARAM *param = X509_STORE_CTX_get0_param(ctx);
if(!(X509_VERIFY_PARAM_get_flags(param) & X509_V_FLAG_USE_CHECK_TIME) || s.validity.empty())
return 1;
for(const TSL::Validity &v: s.validity)
{
if(X509_VERIFY_PARAM_get_time(param) >= v.start && (v.end == 0 || X509_VERIFY_PARAM_get_time(param) <= v.end))
{
X509_STORE_CTX_set_ex_data(ctx, 0, const_cast<TSL::Validity*>(&v));
return 1;
}
}
}
return ok;
}
default: return ok;
}
}
示例7: 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;
}
示例8: Remove
void Remove( TiXmlElement* element, const set<string>& tagsToRemove )
{
TiXmlElement* curr = element->FirstChildElement( );
while( curr != nullptr )
{
TiXmlElement* next = curr->NextSiblingElement( );
if( tagsToRemove.find(curr->ValueStr()) != tagsToRemove.cend() )
{
element->RemoveChild( curr );
}
curr = next;
}
}
示例9: 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();
}
示例10: 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;
}
示例11:
set<M> operator+ (const set<M>& lhs, const set<M>& rhs){
set<M> U{lhs};
U.insert(rhs.cbegin(), rhs.cend());
return U;
}
示例12: main
int main()
{
//the next few lines are to set unbuffered cin
//it means you don't have to press [enter] in the keyboard
//
tcgetattr(STDIN_FILENO,&old_t);//gets the current terminal setings.
new_t=old_t;
new_t.c_lflag &=(~ICANON & ~ECHO);//disable ...
tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered
// *****************************************************
size_t number_partidas;
size_t number_projects=0;
while(1)
{
main1=&main2;
char option=main1->menu();
bool ok;
switch(option)
{
case 'w':
//write a new partida
/* restore the former settings */
tcsetattr(STDIN_FILENO,TCSANOW,&old_t);//buffered keyboard
ok = true;
try
{
main1 -> enter_data ();//we've filled a new object
}
catch(const char* e)
{
cout<<"errooooor !!!!!!"<<endl;
cout << endl << e << endl;
ok = false;
}
if(ok)
{
cont_main2.insert(main2);
// int a=3;
if(!project.size()) project.push_back(cont_main2);
else
{
project.pop_back();
project.push_back(cont_main2);
}
}
else cout << "I have inserted no partida";
tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered
break;
case 'p':
//see a specific partida
cout << "\n\n";
// string part=main2.partida;
/* restore the former settings */
tcsetattr(STDIN_FILENO,TCSANOW,&old_t);//keyboard buffered
cin>>main2.parti;
tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered
//converses string to float
main2.find_partida(main2.parti);//find out the actual number
cout << fixed << setprecision(2);//only 2 decimals
// main2.find_partida(main2.partida);
p=cont_main2.find(main2);//it is in cont_main2
if(p != cont_main2.cend())
{
main2 = *p;
main1 = &main2;
//main1->print_partida(main2);//p contains a object (partida
main1 -> print_partida(main2);//p contains a object (partida
cout << "\nEdit ? (y/n)";
char ed;
cin >> ed;
if(ed == 'y' || ed == 'Y')main1->edit();
//.........这里部分代码省略.........