reallocation

This is a discussion on reallocation within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, We alway meet with the term reallocation, but after some deep thinking, I am confused what exact definition ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    reallocation

    Hello everyone,


    We alway meet with the term reallocation, but after some deep thinking, I am confused what exact definition of what means reallocation. Here is some statements from the book The C++ Standard Library as quoted below.

    My two questions,

    1. How do you understand the term reallocation in the book quoted section?

    2. Are there any standard definition for reallocation?

    My understanding, reallocation means making storage larger or smaller (or making the same size, but different address? not sure?), whether or not it involves free existing memory (e.g. vector) or not (e.g. deque) depends on internal implementation. It is hard to find a suitable definition for reallocation, if you have, please share with me. :-)

    section 6.3.1 Abilities of deques

    --------------------
    Deques provide no support to control the capacity and the moment of reallocation. In particular, any insertion or deletion of elements other than at the beginning or end invalidates all pointers, references, and iterators that refer to elements of the deque. However, reallocation may perform better than for vectors, because according to their typical internal structure, deques don't have to copy all elements on reallocation.
    --------------------


    thanks in advance,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I disagree with this definition. In my opinion, a deque simply doesn't perform reallocation, only allocation and deallocation.

    There's no standard, though.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    How do you understand the reallocation term if you do not agree with me in the quoted statement?

    section 6.3.1 Abilities of deques

    --------------------
    Deques provide no support to control the capacity and the moment of reallocation. In particular, any insertion or deletion of elements other than at the beginning or end invalidates all pointers, references, and iterators that refer to elements of the deque. However, reallocation may perform better than for vectors, because according to their typical internal structure, deques don't have to copy all elements on reallocation.
    --------------------

    Quote Originally Posted by CornedBee View Post
    I disagree with this definition. In my opinion, a deque simply doesn't perform reallocation, only allocation and deallocation.

    There's no standard, though.

    regards,
    George

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Can you explain to me just why you repeat the quote?


    Anyway, I gave my definition of reallocation in another thread.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    After reading your another thread, I understand your points. Your points are, you do not agree with the author of the book to use term reallocation, since in your points, there is no cencept and operation of reallocation for deque. Right?

    Quote Originally Posted by CornedBee View Post
    Can you explain to me just why you repeat the quote?


    Anyway, I gave my definition of reallocation in another thread.

    regards,
    George

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Correct.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    Question answered.

    Quote Originally Posted by CornedBee View Post
    Correct.

    regards,
    George

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,339
    Insertion in the middle of a deque causes elements to be moved, which invalidates iterators, references, etc. Apparently Stroustrup (edit: I mean Josuttis) is referring to this as reallocation.
    Last edited by Daved; 03-05-2008 at 11:44 AM.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The book in question is Josuttis's, I think.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Hi Daved,


    If you have found a formal definition for what is a reallocation in STL, please feel free to share with us, and I think it will definitely bring benefit to us.

    Quote Originally Posted by Daved View Post
    Insertion in the middle of a deque causes elements to be moved, which invalidates iterators, references, etc. Apparently Stroustrup (edit: I mean Josuttis) is referring to this as reallocation.

    Quote Originally Posted by CornedBee View Post
    The book in question is Josuttis's, I think.
    Yes, CornedBee, I am talking about this book,

    --------------------
    C++ Standard Library, The: A Tutorial and Reference


    Nicolai M. Josuttis
    Publisher: Addison Wesley
    First Edition August 06, 1999
    ISBN: 0-201-37926-0, 832 pages
    --------------------


    regards,
    George

  11. #11
    Registered User
    Join Date
    Jan 2005
    Posts
    7,339
    >> If you have found a formal definition for what is a reallocation in STL.

    I have not. I doubt that such a formal definition exists. I don't think it matters that much, as usually we can determine the meaning by the context of the statement.

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Daved,


    I also do not find it out from wikipedia.

    Quote Originally Posted by Daved View Post
    >> If you have found a formal definition for what is a reallocation in STL.

    I have not. I doubt that such a formal definition exists. I don't think it matters that much, as usually we can determine the meaning by the context of the statement.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Memory reallocation in C++
    By spank in forum C++ Programming
    Replies: 2
    Last Post: 08-08-2007, 09:56 AM
  3. reallocation
    By vb.bajpai in forum C Programming
    Replies: 3
    Last Post: 06-17-2007, 05:51 AM
  4. Can reducing a vector's size cause a reallocation?
    By robatino in forum C++ Programming
    Replies: 19
    Last Post: 04-12-2007, 12:13 PM
  5. dynamic reallocation
    By ichijoji in forum Game Programming
    Replies: 4
    Last Post: 05-06-2004, 09:35 AM

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