473,387 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

std::set::upper_bound

Can you create std::set::upper_bound function just using
std::set::lower_bound ?

Apr 12 '06 #1
3 2808
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


Yes, but why would you want to?
Apr 12 '06 #2
Andre Kostur wrote:
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


Yes, but why would you want to?


On further thought, maybe. Depends on what you mean by "just using
std::set::lower_bound".
Apr 12 '06 #3
asdf wrote:
Can you create std::set::upper_bound function just using
std::set::lower_bound ?


I think this works:

iterator upper_bound(const key_type& k)
{
iterator lb = lower_bound(k);
if (lb != end() && key_comp(*lb,k))
++lb;
return lb;
}

-Mark
Apr 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Michael Klatt | last post by:
I am trying to write an iterator for a std::set that allows the iterator target to be modified. Here is some relvant code: template <class Set> // Set is an instance of std::set<> class...
4
by: Marcelo Pinto | last post by:
Hi all, In a class of mine I tried to use the following member: std::map<std::string, std::set<std::string> > m_files; but I recieved the following error message: mips-tfile,...
2
by: jesper | last post by:
In frustration I made this code using equal_range. It does not behave in the way I expected however. It finds the correct breakpoint in the set but finds it as the first iterator. why? I would...
0
by: asdf | last post by:
Can you create std::set::upper_bound function just using std::set::lower_bound ?
5
by: Fred Zwarts | last post by:
I have an application which uses maps. I need to find elements in the map, without knowing the exact key value. I thought I could use the lower_bound, or upper_bound function for this purpose....
4
by: temper3243 | last post by:
Hi, If i have an array like {1,4, 10, 15 , 20 , 30 } of size n , now if i want to search for number 25 , i should get 20 , if i search for number 11 i hould get 10 , if i search for 4 i...
5
by: jpalecek | last post by:
Hello, I know there is a method "insert with hint" int std::set. But there isn't anything similar for find and erase. Does somebody know why? Regards Jiri Palecek
7
by: Adrian | last post by:
Hi, I want a const static std::set of strings which is case insensitive for the values. So I have the following which seems to work but something doesnt seem right about it. Is there a better...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.