Re: std::vector memory allocation

Discussion in 'C++' started by Andrew Koenig, Jun 25, 2003.

  1. onion> When a std::vector has to allocate more memory, am I correct in
    onion> thinking that it allocates additional memory of equal size to
    onion> the amount of memory required to store the existing number of
    onion> elements?

    There is no particular requirement on how much memory to allocate,
    except that the strategy must be such that it offers amortized
    constant time for appending an element. Increasing the existing space
    by any positive constant multiple is enough to meet that requirement.
    There are other strategies that work too.

    --
    Andrew Koenig
    Andrew Koenig, Jun 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chandra Shekhar Kumar

    Re: std::vector memory allocation

    Chandra Shekhar Kumar, Jun 25, 2003, in forum: C++
    Replies:
    0
    Views:
    2,282
    Chandra Shekhar Kumar
    Jun 25, 2003
  2. tom_usenet

    Re: std::vector memory allocation

    tom_usenet, Jun 25, 2003, in forum: C++
    Replies:
    0
    Views:
    1,082
    tom_usenet
    Jun 25, 2003
  3. Ken
    Replies:
    24
    Views:
    3,863
    Ben Bacarisse
    Nov 30, 2006
  4. Replies:
    8
    Views:
    1,915
    Csaba
    Feb 18, 2006
  5. Rune Allnor
    Replies:
    4
    Views:
    944
    Rune Allnor
    Dec 11, 2008
Loading...

Share This Page