Tessil / ordered-map

C++ hash map and hash set which preserve the order of insertion
MIT License
512 stars 66 forks source link

Add lower_bound function #27

Closed markand closed 4 years ago

markand commented 4 years ago

Hello,

We are interesting in using your ordered map because it handle allocation better than standard std::map for very big data.

However, we do need lower_bound function in the map which seems not implemented. For now I'm not sure if I can use std::lower_bound over begin()/end() until there is one which seems to be extremely inefficient.

Do you plan to add this function? I'm not enough fluent with containers to propose a patch :(

Tessil commented 4 years ago

Hi,

A tsl::ordered_map preserves the insertion order in a way similar to Python's OrderedDict. It doesn't sort the elements like a std::map and is more similar to a std::vector. Providing a lower_bound method would not make sense.

If you guarantee by yourself that all the elements are inserted in a sorted order, you can use std::lower_bound with the iterators provided by tsl::ordered_map in a way similar to a sorted std::vector.

Thibaut