The C++ standard seems to make no statement regarding side-effects on capacity by either
resize(n)
, with n < size()
, or clear()
.
It does make a statement about amortized cost of push_back
and pop_back
- O(1)
I can envision an implementation that does the usual sort of capacity changes
ala CLRS Algorithms (e.g. double when enlarging, halve when decreasing size to < capacity()/4
).
(Cormen Lieserson Rivest Stein)
Does anyone have a reference for any implementation restrictions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…