Hi
I need help with which type of container should I use...
I need the data in the array to be :
- sorted
- Quick for insert and delete as well ( cause the program tend to do that alot )
- The program iterate always from the index 0 to some point in array usually not until the end
> list has a sort function:
I'm not sure what are you suggesting.
Merge sort is O(n lg n), it's a little costly for an insertion operation.
> so should I build my own insert sort
That'll be O(n), still too much.
I suggest you to use std::set for O(lg n) insert and erase.
I can't assure you that the iteration will be O(n), but it could not be higher than O(n lg n)
> (double linked list) improves the speed when it comes to sorting.
¿how so?
The basic difference : vector,map and list????? And usage of map (if possible)??
vector mimics an array. it's designed for fast access of the single element. insert/delete of a particular element is rather slow.
list is desinged for fast insert/delete of an element. accessing a particular element is not as fast as vector.
map is somehow a combination of vector and list. It's designed to access a particular element via a key. The key can be of any type (if the key was an index it would appear like a vector (not time wise of course)). It is sorted according to the key, hence the key needs to be comparabel with <