How about replacing the vector with std::map with the int (id) as key and my_structure value.