I am currently using a std::vector<int> vec of size nto store the integers from 0 to n-1 in any order. Suppose that the vec is given by the following:
std::vector<int> vec = {4, 1, 2, 0, 3};
I need to
- iterate over
vecin order, i.e. 4 -> 1 -> 2 -> 0 -> 3. - access specific elements by index
vec[3]-> 0. - remove specific elements by value
del vec[2]->{4, 1, 0, 3}.
The vector is given a priori and the maximum size is known (as we never add elements). What data structure would be suitable here (having performance in mind)?
Aucun commentaire:
Enregistrer un commentaire