reserve(), vector allocation

This is a discussion on reserve(), vector allocation within the C++ Programming forums, part of the General Programming Boards category; When I pass reserve() a value high enough that may mean the need for reallocation, is the vector reallocated immediately ...

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438

    reserve(), vector allocation

    When I pass reserve() a value high enough that may mean the need for reallocation, is the vector reallocated immediately or only at next push_back()?
    Last edited by Mario F.; 06-12-2006 at 10:28 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,630
    Memory should be reallocated immediately.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Thanks laserlight.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. capacity and reserve
    By George2 in forum C++ Programming
    Replies: 33
    Last Post: 03-06-2008, 07:14 PM
  2. reserve method of vector
    By George2 in forum C++ Programming
    Replies: 11
    Last Post: 11-15-2007, 02:24 PM
  3. airline reserve system
    By strider496 in forum C Programming
    Replies: 2
    Last Post: 04-09-2005, 02:48 PM
  4. Reserve the character in a string
    By alice in forum C Programming
    Replies: 2
    Last Post: 06-13-2004, 07:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21