Steven Schveighoffer Wrote: > int[] a; > a.setCapacity(10000); // pre-allocate at least 10000 elements.
I would prefer the name reserve(). It has precedent in the STL, and the method doesn't actually always set the capacity, only if the current capacity is less then the argument. Even then it may conceivably allocate more than was asked for. In other words, the name setCapacity suggests this will always succeed: a.setCapacity(n); assert(a.capacity == n); ...which is not the case as far as I can tell.
