set-equal_range

////////////////////////////////////////
//      2018/04/28 14:04:28
//      set-equal_range
#include 
#include 

using namespace std;

int main(){
    set<int> c;

    c.insert(1);
    c.insert(2);
    c.insert(4);
    c.insert(10);
    c.insert(11);


    // find leftmost node not less than(不小于) _Keyval in mutable tree
    cout << "lower_bound(3):"
        << *c.lower_bound(3) << endl;

    // find leftmost node greater than(大于) _Keyval in mutable tree
    cout << "uper_bound(3):"
        << *c.upper_bound(3) << endl;

    // find range equivalent to _Keyval in mutable tree
    cout << "equal_range(3):"
        << *c.equal_range(3).first << " " // lower_bound  bpund(弹跳,限制,界限)   
        << *c.equal_range(3).second << endl;   // uper_bound
    cout << endl;


    cout << "lower_bound(5):"
        << *c.lower_bound(5) << endl;
    cout << "uper_bound(5):"
        << *c.upper_bound(5) << endl;
    cout << "equal_bound(5):"
        << *c.equal_range(5).first << " "
        << *c.equal_range(5).second << endl;

    return 0;
}

/*
OUTPUT:
    lower_bound(3):4
    uper_bound(3):4
    equal_range(3):4 4

    lower_bound(5):10
    uper_bound(5):10
    equal_bound(5):10 10
*/

你可能感兴趣的:(STL)