Results 1 to 10 of 10

Thread: Simple question about list of one dimensional arrays.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Simple question about list of one dimensional arrays.

    I did not mean to imply that these classes were equal to std::array.

    However, the var length array will be very similar, it will also allocate the given size on the stack. An alternative if C++11 is not available.

    Not sure what you mean with indirection though.

    Cheers,
    _

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Simple question about list of one dimensional arrays.

    What I mean by "indirection" is an access that involves dereferencing a pointer. QVector needs at least one level of indirection since it allocates its elements on the heap, and perhaps another one due to implicit sharing. A QVarLengthArray has two modes, depending on whether it uses the storage on the stack (no indirection) or on the heap (one indirection). Even though the former mode avoids the indirection, it uselessly allocates storage for two integers and a pointer, and each access to an element must test the mode.

    QVector and QVarLengthArray are overkill for 6 integers and lack the typing guarantees of a plain array, or even
    Qt Code:
    1. struct ArrayInt6 {
    2. int elements[6];
    3. }
    To copy to clipboard, switch view to plain text mode 
    when C++11 is not an option.

Similar Threads

  1. QTestLib. A simple example. A list of the FAILS.
    By 8Observer8 in forum Newbie
    Replies: 6
    Last Post: 5th October 2013, 09:07
  2. Question About Arrays inside functions
    By rdelgado in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2011, 14:27
  3. Replies: 3
    Last Post: 11th June 2009, 04:26
  4. simple question on pointer-arrays
    By mickey in forum General Programming
    Replies: 2
    Last Post: 17th February 2007, 01:11
  5. Another simple question...
    By Dark_Tower in forum Newbie
    Replies: 5
    Last Post: 31st March 2006, 16:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.