Use shared STL instead.
Use const iterators to calculate total.