Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT C++ DATA Structures
Forum Updated to NodeBB v4.3 + New Features

QT C++ DATA Structures

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 3 Posters 863 Views
  • 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.
  • E Offline
    E Offline
    ELIF
    wrote on last edited by
    #1

    How to access any element of stack or queue without pop() operation in c++ ?

    JonBJ 1 Reply Last reply
    0
    • E ELIF

      @JonB yes , ofcourse.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #7

      @ELIF
      Then why not say so from the start?! So your question is not connected to Qt C++ data strictures structures after all. You can see the methods of std::queue from the docs:

      The std::queue class is a container adaptor that gives the programmer the functionality of a queue - specifically, a FIFO (first-in, first-out) data structure.

      The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.

      Accessors are front() and back() It's a queue. So you cannot access middling elements, and why would you want to if you are choosing to use a queue?

      However, @JoeCFD's std::dequeue does allow access to middling elements. See Access c++ queue elements like an array for a discussion.

      1 Reply Last reply
      2
      • E ELIF

        How to access any element of stack or queue without pop() operation in c++ ?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @ELIF
        Depends what library you are using for "stack" or "queue".

        1 Reply Last reply
        0
        • E Offline
          E Offline
          ELIF
          wrote on last edited by
          #3

          I will use queue.

          JonBJ 1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #4

            std::deque may be a better option.

            1 Reply Last reply
            1
            • E ELIF

              I will use queue.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #5

              @ELIF
              What queue? std::queue?

              E 1 Reply Last reply
              0
              • JonBJ JonB

                @ELIF
                What queue? std::queue?

                E Offline
                E Offline
                ELIF
                wrote on last edited by
                #6

                @JonB yes , ofcourse.

                JonBJ 1 Reply Last reply
                0
                • E ELIF

                  @JonB yes , ofcourse.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #7

                  @ELIF
                  Then why not say so from the start?! So your question is not connected to Qt C++ data strictures structures after all. You can see the methods of std::queue from the docs:

                  The std::queue class is a container adaptor that gives the programmer the functionality of a queue - specifically, a FIFO (first-in, first-out) data structure.

                  The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.

                  Accessors are front() and back() It's a queue. So you cannot access middling elements, and why would you want to if you are choosing to use a queue?

                  However, @JoeCFD's std::dequeue does allow access to middling elements. See Access c++ queue elements like an array for a discussion.

                  1 Reply Last reply
                  2
                  • E Offline
                    E Offline
                    ELIF
                    wrote on last edited by
                    #8

                    @JonB said in QT C++ DATA Structures:

                    strictures

                    Thank you :)

                    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