Why use map than with a long long one dimensional array of time-consuming Just pay a problem, just change the map to the array, take from 2 s to 0.12 s
When should also use the map is ok (I only know that in a set of number n, when n is particularly big, can't use a one-dimensional array need to use) grateful!!
CodePudding user response:
No can not use ah, you say is the STL map a map? This is a class, with the mapping, affirmation is slower than the separate use Numbers, if digital particularly big, dynamically allocated array, if the dynamic distribution, then crashed,
CodePudding user response:
Because the map is different from the structure of the array, a tree map layer structure, for example, defines a sequence of a, you want to visit a [10000], array size first address directly 10000 *, one can access to, and the map to search again, when using a map? Cannot use arrays in map, the keys of the map if it is a positive integer, of course it is better to use an array