Original Post
Hi, I am trying to optimise my C++ A* algorithm but cannot find what I am after in the standard template library, but that might just indicate my lack of search skills. I need a container in which I can easily get the smallest element. The most efficient way to do this in my mind would be to use a sorted container. If I wasn't bothered about the speed I would just use an stl vector and use sort() each time I inserted an element. But I suspect it would be much more efficient to actually insert the element in the correct place. So vector is out of the question. I came across this STL compliant "sorted_vector": http://www.codeproject.com/vcpp/stl/sorted_vector.asp But it points out the fact that insertions are rather slow being that it is a vector and all. What would seem the best solution to me is a sorted linked list. This allows insertion in O(n) and obtaining the smallest element in O(1). But I am not aware of an STL implementation of a sorted linked list. Could write my own but there is always that luxury of knowing a container is properly optimised when it is official.