Results 1 to 3 of 3

Thread: extracting QVectors from a multidimensional QVEctor array

  1. #1
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    39
    Thanks
    15
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default extracting QVectors from a multidimensional QVEctor array

    Hello,

    If I have an array that is defined by a QVector<Qvector<QVector<double> > > and lets say its dimensions are [7, 10000, 5] is there any easy way for me to extract the data from a given dimension without having to run for loops?
    e.g. I want to extract the first entry of the last dimension so I have an new array that is size [7, 10000], or lets say I want to extract the 10th entry of the second dimension so I have a new [7,5] array etc etc

    In a programming language I was using before (an interpreted language) I could for example request the first case I used above by saying new_array = old_array[*,*,0] where the * tells the program to get all of the entries in those dimensions, or in the second case new_array = old_array[*,9,*]

    My Qt code I have at the moment works and I guess it is fast enough for me but if I can avoid another set of for loops I would like to

    Cheers
    Oz

    or pending a lack of any method etc, a recommended strategy would be cool as well
    Last edited by OzQTNoob; 22nd February 2012 at 13:34.

  2. #2
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    39
    Thanks
    15
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: extracting QVectors from a multidimensional QVEctor array

    Ok so assuming it isn't a question that's going to be answered I guess the alternative is can someone show me how to use the foreach statement with multidimensional QVectors?

    Cheers
    Oz

  3. #3
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: extracting QVectors from a multidimensional QVEctor array

    Qt Code:
    1. QVector<QVector<QVector<int>>> vvv;
    2.  
    3. foreach (QVector<QVector<int>> vv, vvv)
    4. foreach (QVector<int> v, vv)
    5. foreach (int i, v)
    6. std::cout << i;
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to mentalmushroom for this useful post:

    OzQTNoob (23rd February 2012)

Similar Threads

  1. QVector array declear
    By zhxys in forum Newbie
    Replies: 8
    Last Post: 2nd February 2011, 09:17
  2. Replies: 1
    Last Post: 4th August 2010, 17:13
  3. use QVector as 2 dimensional Array
    By umulingu in forum Qt Programming
    Replies: 3
    Last Post: 1st January 2010, 12:31
  4. QVector crashes when array size is big
    By Sheng in forum Qt Programming
    Replies: 49
    Last Post: 27th February 2009, 22:13
  5. QVectos to multidimensional array
    By zorro68 in forum Qt Programming
    Replies: 21
    Last Post: 16th March 2007, 14:45

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.