本文整理汇总了C++中set::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ set::rend方法的具体用法?C++ set::rend怎么用?C++ set::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set
的用法示例。
在下文中一共展示了set::rend方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get_START_Boundary_Range_For_END
int CDetCandit::Get_START_Boundary_Range_For_END(set<size_t>& START_s, set<size_t>& END_s, int Curposit, int limit)
{
int FeedBorder = limit;
for(set<size_t>::reverse_iterator rsite = START_s.rbegin(); rsite != START_s.rend(); rsite++){
if((int)*rsite < Curposit){
FeedBorder = *rsite;
break;
}
}
set<size_t>::reverse_iterator rsite;
for(rsite = END_s.rbegin(); rsite != END_s.rend(); rsite++){
if(((int)*rsite < Curposit) && ((int)*rsite < FeedBorder)){
FeedBorder = *rsite;
break;
}
}
/*for(rsite = END_s.rbegin(); rsite != END_s.rend(); rsite++){
if(((int)*rsite < Curposit) && ((int)*rsite < FeedBorder)){
FeedBorder = *rsite;
break;
}
}*/
/*if(FeedBorder < Curposit){
FeedBorder++;
}*/
/*set<size_t>::reverse_iterator rsite;
for(rsite = END_s.rbegin(); rsite != END_s.rend(); rsite++){
if((int)*rsite < Curposit){
FeedBorder = *rsite;
break;
}
}*/
/*if(rsite != END_s.rend()){
rsite++;
if(rsite != END_s.rend()){
FeedBorder = *rsite;
}
}
if(rsite != END_s.rbegin()){
FeedBorder++;
}*/
if(FeedBorder < limit){
FeedBorder = limit;
}
for(int i = CAND_FEEDBACK_NUM; (i >= 0) && (FeedBorder > limit); i--){
FeedBorder--;
}
return FeedBorder;
}
示例2: main
int main() {
using namespace std;
string wood { "Appletreetrunk" };
cout << hex << wood.size() << dec << '\n'; // *** 0 ***
set<char> const s{wood.begin(), wood.end()};
cout << s.size() << '\n'; // *** 1 ***
cout << ++*wood.begin() << '\n'; // *** 2 ***
cout << *s.begin() << '\n'; // *** 3 ***
auto it1 = s.begin(); ++it1;
cout << *it1 << '\n'; // *** 4 ***
auto it2 = s.rend(); advance(it2, -3);
cout << *it2 << '\n'; // *** 5 ***
auto it3 = wood.end(); advance(it3, 3);
cout << * it3 << '\n'; // *** 6 ***
auto it4 = s.end(); it4--; it4--;
cout << * --it4 << '\n'; // *** 7 ***
return 0;
}
示例3: main
int main(void)
{
int N;
int remain=0;
string name,operation;
cin>>N;
for (int i=0;i<N;i++)
{
cin>>name>>operation;
if (operation=="enter")
{
remain++;
container.insert(name);
}
if (operation=="leave")
{
set<string>::iterator it=container.find(name);
if (it!=container.end())
{
container.erase(it);
remain--;
}
}
}
set<string>::reverse_iterator it_2=container.rbegin();
for (;it_2!=container.rend();++it_2)
cout<<*it_2<<endl;
return 0;
}
示例4: main
int main() {
int t, n;
while (true) {
cin >> t >> n;
if (t + n == 0) break;
vector<int> v(n);
for (int i = 0; i < n; ++i) cin >> v[i];
for (int i = 0; i < n; ++i) {
vector<int> ans;
go (i, 0, t, n, ans, v);
}
if (!st.size()) {
cout << "Sums of " << t << ":" << endl << "NONE" << endl;
continue;
}
cout << "Sums of " << t << ":" << endl;
set< vector<int> > :: reverse_iterator it;
for (it = st.rbegin(); it != st.rend(); ++it) {
vector<int> cur = *it;
cout << cur[0];
for (int j = 1; j < cur.size(); ++j) {
cout << "+" << cur[j];
}
cout << endl;
}
st.clear();
}
return 0;
}
示例5: main
int main()
{
int n;
cin >> n;
for (int i = 2; i <= 2 * n; i++)
for (int j = 1; j < i; j++)
{
int val;
cin >> val;
S.insert(make_pair(val, make_pair(i, j)));
}
vector<int> ans(2 * n + 1);
set<int> toAllot;
for (int i = 1; i <= 2 * n; i++)
toAllot.insert(i);
for (auto it = S.rbegin(); it != S.rend(); it++)
{
int a = (*it).second.first;
int b = (*it).second.second;
if (toAllot.count(a) and toAllot.count(b))
ans[a] = b, ans[b] = a, toAllot.erase(a), toAllot.erase(b);
}
for (int i = 1; i <= 2 * n; i++)
cout << ans[i] << ' ';
return 0;
}
示例6: AGDaemonID_local_timeout_thread
void* AGDaemonID_local_timeout_thread (void* cls) {
struct timespec request;
struct timespec remain;
while (true) {
request.tv_sec = 30;
request.tv_nsec = 0;
remain.tv_sec = 0;
remain.tv_nsec = 0;
int rc = clock_nanosleep(CLOCK_MONOTONIC, 0,
&request, &remain);
if (rc < 0)
perror("clock_nanosleep");
//Traverse the set...
set<AGDaemonID_local*, AGDaemonID_comp>::reverse_iterator itr;
fwd_itr fitr;
for (itr = agd_set.rbegin(); itr != agd_set.rend(); itr++) {
AGDaemonID_local *agdl = *itr;
time_t current_time;
time(¤t_time);
if ((current_time - agdl->pulse_ts) >= agdl->freq * 2) {
syslog(LOG_WARNING, "%s:%i Pulse rate lower than anticipated (%i)\n", agdl->addr.c_str(), agdl->port, agdl->freq);
//ping
PingResponse pr;
thrift_connection *tc = thrift_connect(agdl->addr.c_str(), agdl->port, false);
if (tc->is_connected) {
tc->ag_client->ping(pr);
if (pr.id != agdl->id) {
syslog(LOG_CRIT, "%s:%i Returns an unexpected ID\n", agdl->addr.c_str(), agdl->port);
del_set.insert(agdl);
continue;
}
fitr = agd_set.find(*itr);
agd_set.erase(fitr);
time(&(agdl->pulse_ts));
agd_set.insert(agdl);
}
else {
syslog(LOG_CRIT, "%s at %s:%i", tc->err, agdl->addr.c_str(), agdl->port);
del_set.insert(agdl);
}
thrift_disconnect(tc);
}
else {
break;
}
}
delete_elements();
}
return NULL;
}
示例7: Get_Left_Outer_Feature_Range_For_START
//==============================================
int CDetCandit::Get_Left_Outer_Feature_Range_For_START(set<size_t>& START_s, set<size_t>& END_s, int Curposit, int limit)
{
int FeedBorder = limit;
for(set<size_t>::reverse_iterator rsite = END_s.rbegin(); rsite != END_s.rend(); rsite++){
if((int)*rsite < Curposit){
FeedBorder = *rsite;
break;
}
}
if(FeedBorder < limit){
FeedBorder = limit;
}
return FeedBorder;
}
示例8: calc
int calc() {
int total = 1;
set<pair<int, int> >::reverse_iterator it = data.rbegin();
set<pair<int, int> >::reverse_iterator lastIt = data.rbegin();
it++;
int pos = n - 2;
int lastPos = n - 1;
while (it != data.rend()) {
while (lastIt->first >= it->first + d) {
lastIt++;
lastPos--;
}
total = total * (LLI)(lastPos - pos + 1) % MOD;
it++;
pos--;
}
return total;
}
示例9: Greedy_Right_to_Left_matching
void CDetCandit::Greedy_Right_to_Left_matching(set<size_t>& START_s, set<size_t>& END_s, int Curposit, int limit, size_t Match_Distance, set<size_t>& Match_s)
{
if(END_s.find(Curposit) == END_s.end()){
AppCall::Secretary_Message_Box("Data Error in CDetCandit::Greedy_Right_to_Left_matching()...", MB_OK);
}
size_t loc_Distance = 0;
for(set<size_t>::reverse_iterator rsite = START_s.rbegin(); rsite != START_s.rend(); rsite++){
if((int)(*rsite) <= Curposit){
Match_s.insert(*rsite);
if(++loc_Distance == Match_Distance){
break;
}
}
}
if(Match_s.empty()){
Match_s.insert(limit);
}
}
示例10: set_count
int set_count(set<int> &num, set<int> &st, map<int, int> &mp)
{
set<int>::reverse_iterator rit;
for(rit=num.rbegin(); rit!=num.rend();)
{
int i = *rit;
num.erase(i);
int ct=2;
for(int j : st)
{
if(i==1)
break;
if(st.count(i))
{
mp.count(i) ? mp[i]+=ct : mp[i]=ct;
break;
}
while(i % j == 0)
{
mp.count(j) ? mp[j]+=ct : mp[j]=ct;
i = i/j;
if(num.count(i))
{
num.erase(i);
ct += 2;
}
}
}
}
return 0;
}
示例11: main
int main()
{
string line;
//build library
while(getline(cin,line),line!="END"){
int p = line.find(" by ");
Book book;
string title = line.substr(0,p);
string author = line.substr(p+4);
book.title = title;
book.author = author;
title_to_book[title] = book;
library.insert(book);
}
while(getline(cin,line),line!="END"){
string title;
if(line.substr(0,6)=="BORROW"){
title = line.substr(7);
library.erase(title_to_book[title]);
}else if(line.substr(0,6)=="RETURN"){
title = line.substr(7);
desk.insert(title_to_book[title]);
}else{
//shelve
for(set<Book>::reverse_iterator it=desk.rbegin();it!=desk.rend();it++){
cout<<"Put "<<it->title;
if(library.upper_bound(*it)==library.end()) cout<<" first"<<endl;
else cout<<" after "<<library.upper_bound(*it)->title<<endl;
library.insert(*it);
}
cout<<"END"<<endl;
desk.clear();
}
}
return 0;
}
示例12: x
CPanelHistory::CPanelHistory(const set<wxDateTime> &setDateTime,
wxWindow *parent, wxWindowID id) :
wxPanel(parent,id)
{
m_pButtonBack = new wxButton(this,wxID_ANY,"<<",
wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
m_pButtonBack1 = new wxButton(this,wxID_ANY," < ",
wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
m_pButtonFwd1 = new wxButton(this,wxID_ANY," > ",
wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
m_pButtonFwd = new wxButton(this,wxID_ANY,">>",
wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
wxFont fnt = m_pButtonBack->GetFont();
fnt.SetWeight(wxFONTWEIGHT_BOLD);
m_pButtonBack->SetFont(fnt);
m_pButtonBack1->SetFont(fnt);
m_pButtonFwd->SetFont(fnt);
m_pButtonFwd1->SetFont(fnt);
//
// make combo box
//
// copy wxDateTime from set to vector and
// format strings for combo box
wxArrayString as;
wxString s;
size_t nSIZE = setDateTime.size();
// bool bEMPTY = false;
if(!nSIZE)
{
wxDateTime x((time_t) 0);
nSIZE++;
m_vTime.push_back(x);
}
else
{
m_vTime.reserve(nSIZE);
}
as.Alloc(nSIZE + 1);
as.Add(CHistoryTime::CURRENT);
for(set<wxDateTime>::const_reverse_iterator itr = setDateTime.rbegin();
itr != setDateTime.rend();
++itr)
{
m_vTime.push_back(*itr);
s = nwxString::FormatDateTime(*itr); // format string
as.Add(s); // add to array for combo box
}
m_pComboHistory = new wxComboBox(
this,wxID_ANY,CHistoryTime::CURRENT,
wxDefaultPosition, wxDefaultSize,as,wxCB_READONLY);
//
// combo box has been made, now layout
//
EnableButtons();
int nFLAGS = (wxTOP | wxBOTTOM | wxLEFT | wxALIGN_CENTRE);
wxSizer *pSizer = new wxBoxSizer(wxHORIZONTAL);
pSizer->AddStretchSpacer(1);
pSizer->Add(m_pButtonBack, 0, nFLAGS ^ wxLEFT, ID_BORDER);
pSizer->Add(m_pButtonBack1, 0, nFLAGS, ID_BORDER);
pSizer->Add(m_pComboHistory,0, nFLAGS, ID_BORDER);
pSizer->Add(m_pButtonFwd1, 0, nFLAGS, ID_BORDER);
pSizer->Add(m_pButtonFwd, 0, nFLAGS, ID_BORDER);
pSizer->AddStretchSpacer(1);
SetSizer(pSizer);
pSizer->Layout();
}
示例13: generateDensity
// By going through the list backwards I can ensure the first entry.
void generateDensity( DensityStruct *dStruct) {
int i, mw_int;
for(i = 0; i < MAX_PEPTIDE_MASS*DENSITY_MULTIPLIER; i++) {
dStruct[i].numEntries = 0;
dStruct[i].firstEntry = 0;
}
for(i = globalPeptideSet.size(), revPepSetIter = globalPeptideSet.rbegin(); revPepSetIter != globalPeptideSet.rend(); --i, ++revPepSetIter) {
mw_int = (int) ( (*revPepSetIter).neutralMass*DENSITY_MULTIPLIER);
dStruct[mw_int].numEntries += 1;
dStruct[mw_int].firstEntry = i;
}
/*for(i = 0; i < MAX_PEPTIDE_MASS*DENSITY_MULTIPLIER; i++) {
cout << i << " " << dStruct[i].numEntries << " " << dStruct[i].firstEntry << endl;
}*/
}