Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. start a list from the second element
Forum Updated to NodeBB v4.3 + New Features

start a list from the second element

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 493 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    micheal15
    wrote on last edited by micheal15
    #1

    I would like the var to start from the second line of my list I tried with list.at(1) but it does not work

    std::sort(list.begin, list.end()) ;
    double var =list.at(1)
    

    how can i do it please ?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      " but it does not work"

      what happens ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mchinand
        wrote on last edited by
        #3

        Add debugging to output your original list, and your sorted list. Is the sorted result what you expect?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          micheal15
          wrote on last edited by
          #4

          can we do : list.(first()-1) or list.(last()-1) ?

          M 1 Reply Last reply
          0
          • M micheal15

            can we do : list.(first()-1) or list.(last()-1) ?

            M Offline
            M Offline
            mchinand
            wrote on last edited by
            #5

            @micheal15 No one knows since you're not telling us what isn't working

            1 Reply Last reply
            2
            • Kent-DorfmanK Offline
              Kent-DorfmanK Offline
              Kent-Dorfman
              wrote on last edited by
              #6

              what is list? a vector, a list? what? not looking at the docs, but I'm not sure that std::list even supports the at() method...and upon checking...no, it does not.

              If you meet the AI on the road, kill it.

              1 Reply Last reply
              0
              • Kent-DorfmanK Offline
                Kent-DorfmanK Offline
                Kent-Dorfman
                wrote on last edited by Kent-Dorfman
                #7

                for what its worth: use the ugly option below, or switch to a container that supports random element access

                auto obj = list.front();
                list.pop_front();
                auto atOne = list.front();
                list.push_front(obj);
                

                If you meet the AI on the road, kill it.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved