stl list dynamic allocation

This is a discussion on stl list dynamic allocation within the C++ Programming forums, part of the General Programming Boards category; It can't be reassigned to another instance? (If I recall correctly that's the usual practice in Java.)...

  1. #16
    Registered User
    Join Date
    Feb 2003
    Posts
    595
    It can't be reassigned to another instance? (If I recall correctly that's the usual practice in Java.)

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    You can reassign pointers, but not references. In C++ a reference is just an alias.

  3. #18
    Registered User
    Join Date
    Feb 2003
    Posts
    595
    OK, thanks again.

  4. #19
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,307
    Lists have higher overhead per-item and are worse for the cache performance, and worse for memory fragmentation, than vectors.
    It is thus preferable to use a vector rather than a list if you don't need to insert or remove items anywhere but the end. So you may find that you get better performance with a list of vectors, or a vector of lists, or even a vector of vectors.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #20
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    Why do people never talk about 'valarray's ? I've read very contradictionnary articles/posts about it. I think it is much faster than vector since there is no or less memory management and overhead, but the valarray does not seem to be so popular.

    An argument for me to use valarrays is the slicing we can perform. We can get column and row vectors, both at (approximately) the same speed. This is not possible with a vector of vectors I think.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help sorting a linked list. Beginner
    By scarlet00014 in forum C Programming
    Replies: 1
    Last Post: 09-27-2008, 06:16 PM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. problem with structures and linked list
    By Gkitty in forum C Programming
    Replies: 6
    Last Post: 12-12-2002, 05:40 PM
  4. 1st Class LIST ADT
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-09-2001, 06:29 PM

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