C ++ STL
Iterator lower_bound (const key_type & Key );
Iterator upper_bound (const key_type & Key );
Function Functions
Iterator lower_bound (const key_type & Key): returns an iterator pointingKey value>= Key.
Iterator upper_bound (const key_type & Key): returns an iterator pointingKey Value> Key.
Lower_bound () function
First version:
Template <class forwarditerator, class type>
Forwarditerator
Lower_bound (forwarditerator first,
Forwarditerator last, const type & value );
Version 2:
Template <class forwarditerator, class type, class compare>
Forwarditerator
Lower_bound (forwarditerator first,
Forwarditerator last, const type & value,
Compare comp );
Function Introduction
Lower_bound () returns an iterator that points toOrdered sequenceCan insert value, without disrupting the first position of the container order, and this position marksGreater than or equalValue.
For example, there are the following sequences:
IA [] = };
Use Value 21 to call lower_bound () and return an iterator pointing to 22. Call lower_bound () with the value 22, and return an iterator pointing to 22. The first version uses the underlying <(less than) operator, and the second version performs sorting and comparison based on comp.
Notes
Before calling lower_bound, you must determine the sequence as an ordered sequence; otherwise, an error occurs in the call. The first version is sorted by the underlying <(less than) operator, and the second version is sorted by comp.