I have 2 versions of the exact same program, maze generator, written in Python and C++. What i thought after optimizing it in Python is that, if i rewrite it in C++ it will be much faster and more efficient. However, i discovered one surprising thing (well not that surprising when you think about it). For Python: my algorithm picks a random item from the list, processes it and deletes it from there afterwards. For C++: all the same, but instead of list i use vector. Deleting elements from a vector in C++ is much slower than doing the same for a list in Python because vector's elements shift when you delete on of them. My question is: What is the best data structure in C++ that can be indexed and performs deletion of its items faster than vector?
Right now C++'s deletion takes 5-6 times more time than Python's on average.