Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java library have functions like std::lower_bound() , std::upper_bound() in C++ ? [duplicate]

Are there any other alternatives to achieve the same in Java ? In C++, I can use these wonderful methods and make my life easier. Is it possible in Java too ? My sole aim is to write code which is simple and clean and which is not error prone.

like image 522
sumanth232 Avatar asked Nov 02 '22 07:11

sumanth232


1 Answers

Java class TreeSet which is based on search tree of comparable objects instead of hash table has similar methods floor and ceiling. More generic methods for any iterable type you are free to implement by yourself.

like image 71
Odomontois Avatar answered Nov 13 '22 18:11

Odomontois