Results 1 to 8 of 8

Thread: stl vector uses link list ?????????

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    222

    stl vector uses link list ?????????

    stl vector uses link list ?????????

  2. #2
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking no...

    Linked lists are not contiguous, and the getting of data not at the ends is linear, not constant time.

    Vectors on the other hand are all stored in one big block of memory (moved and doubled in size when necessary) so that you can get elements in constant time.

    I don't see how one can store the other...


    However, if i remember correctly, deques have some strange list-type structure that gives pointers to large blocks of memory, so access is almost constant... but it is certainly not one big long list.
    sql_lall

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    222

    stl vector uses link list ?????????

    You mean it is a dynamic array.

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Yeah basically. The major difference between the two is random access.

    Check out my vectro info
    http://www.techno-coding.com/pages/t...tor/vector.htm

    I also have some basic tutorials for vectors as well.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    222

    stl vector uses link list ?????????

    How does vector allocate memory?

  6. #6
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    With an allocator object, which asks the system for the memory. (and may do other stuff - you can write your own allocator for special purposes).
    an ending

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2004
    Posts
    222

    stl vector uses link list ?????????

    Thanks.
    If I want to add new items in the vector then
    it creates a new array of new size and copy the old array into it and delete the old array.Is it?

  8. #8
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    If there's not enough space for the new item, it will have to allocate a new array and copy, yes. But when it has to do that, it will allocate more memory than it's currently using (doubling in size I think) so that when you add more items in the future, it doesn't have to allocate and copy every time.
    an ending

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width