Im working with a std::list
.
Elements appear in "order of insertion" into the list, not according to the value of an element.
When std::find()
-ing an element, the whole list must be searched.
In order to speed up "finding" from O(n) to O(log(n)) I could myself implement a hash-map to store the std::list
elements positions, or I could use boost Multi Indexes, https://www.boost.org/doc/libs/release/libs/multi_index/doc/tutorial/basics.html#list_fast_lookup.
Question: Today, with C++17, is there a standard/common or a best-practices way of implementing a container that have all the properties of a list PLUS fast find
(and, eg. remove
)? Or, does such a container type already exist? C++20 perhaps?
Edit/Nb: The order of the elements in the list is relevant and thus a std::map can not directly be used.