Taking values from Queue

D

Donos

Hello

I am working on a design in which there is a Queue which will read
data from a database. This happens in one particular class.

Class CRecieveData
{
std::queue<unsigned char> m_RxQueue;
}

Here the data is added into Queue using "push" function.

Now as per the design i have to extract the data from Queue in another
Class using Deque.

class CDecodeData
{
// Need to add code here to extract data from Queue declared
in another class, using Deque Iterator
}

ie, by using an Iterator of Deque.

Can anyone tell me how to do this?

Thanks.
 
V

Victor Bazarov

Donos said:
I am working on a design in which there is a Queue which will read
data from a database. This happens in one particular class.

Class CRecieveData
{
std::queue<unsigned char> m_RxQueue;
}

Here the data is added into Queue using "push" function.

Now as per the design i have to extract the data from Queue in another
Class using Deque.

class CDecodeData
{
// Need to add code here to extract data from Queue declared
in another class, using Deque Iterator
}

ie, by using an Iterator of Deque.

Can anyone tell me how to do this?

Nobody can tell you. There is no way to extract an object from
a std::queue using an object of an unrelated type (iterator to some
std::deque). Even though 'std::queue' can be implemented using
'std::deque' as its underlying container, there is no standard way
to go from an iterator to a 'deque' to the 'queue' the 'deque' is
used to implement. Make sure the reference to the actual 'queue'
is passed to your scope.

V
 
D

Donos

Ok. Like i said, the Queue is declared as,

std::queue<unsigned char> m_RxQueue;

and the data is pushed into Queue using,

m_RxQueue.push(*pBuf++);

Where pBuf is a unsigned char*

---------------------------------------------

And my question is, Now how can i extract the data back?

If not a Deque::Iterator, what other approach i can use to extract
data from Queue?
 
G

Guest

Ok. Like i said, the Queue is declared as,

std::queue<unsigned char> m_RxQueue;

and the data is pushed into Queue using,

m_RxQueue.push(*pBuf++);

Where pBuf is a unsigned char*

---------------------------------------------

And my question is, Now how can i extract the data back?

If not a Deque::Iterator, what other approach i can use to extract
data from Queue?

front() and pop(), if they are not enough then a queue is not what you want.
 
V

Victor Bazarov

Erik said:
front() and pop(), if they are not enough then a queue is not what
you want.

I am really trying hard not to use "RTFM" in my replies, yet they
do sometimes trickle through. How do you manage?

V
 
G

Guest

I am really trying hard not to use "RTFM" in my replies, yet they
do sometimes trickle through. How do you manage?

I got a lot of spare time at the moment, so I can afford to be patient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,199
Messages
2,571,045
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top