About the common STL little experience

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/Mr_zhuo_/article/details/88552490

1. the Vector to do dynamic array is very convenient,

But to consider the code often accidentally crossed the line: v, v can not directly access the unassigned [i] = XXX, it is not defined, the value can not be left only push_back ().

And therefore can not jump assignment. This is not as flexible array.

 

2. the SET can automatically sort, eliminate duplication

 But this is not accessible to s [i], even if provided it, * (it) is, but * (it + i) is wrong. So random access a lot of trouble. Recommendation back to the array.

 

3. the Map to-one mapping

But when the initial value can only assign one by one, very strenuous. Only in accordance mapped access, such mp [ 'c'] = 1;

If the hash chain to establish a similar, careful ah, anyway, I have not succeeded. Next try.

 

4. pair is also good, because the object is only one, do not visit it each have their own troubles (careful cross-border) to the array. But, the case can be used with a pair of vector

 

5. be updated. . .

Guess you like

Origin blog.csdn.net/Mr_zhuo_/article/details/88552490