Re: Free STL compatible C++ tree container

Discussion in 'C++' started by Juha Nieminen, Aug 7, 2012.

  1. Leigh Johnston <> wrote:
    > http://i42.co.uk/stuff/tree.htm


    Btw, an optimization commonly used in STL implementations with regards
    to the assign() function of most data containers (especially those that
    allocate individual elements) is to reuse existing elements while
    assigning, rather than first clearing the entire data container and
    then inserting the elements.

    In other words, when assigning (with the assign() member function),
    the input values are assigned to any existing elements of the container.
    If the container had less elements than what is being assigned, the rest
    are then inserted to the end normally, and it had more, the extra is
    removed normally.

    This has the obvious advantage that the amount of allocations and
    deallocations is minimized, making the assignment faster (and reducing
    memory fragmentation).
     
    Juha Nieminen, Aug 7, 2012
    #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. Replies:
    4
    Views:
    815
    Daniel T.
    Feb 16, 2006
  2. Nordlöw
    Replies:
    2
    Views:
    812
    Marcel Müller
    Apr 16, 2008
  3. Luca Risolia
    Replies:
    12
    Views:
    674
    Luca Risolia
    Aug 11, 2012
  4. TDH1978
    Replies:
    6
    Views:
    626
    TDH1978
    Aug 10, 2012
  5. Ansel
    Replies:
    1
    Views:
    412
    Juha Nieminen
    Aug 16, 2012
Loading...

Share This Page