|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Donos wrote:
> 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 -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 2007-10-18 20:19, Donos wrote:
> 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. -- Erik Wikström |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Erik Wikström wrote:
> On 2007-10-18 20:19, Donos wrote: >> 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. I am really trying hard not to use "RTFM" in my replies, yet they do sometimes trickle through. How do you manage? V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2007-10-18 21:06, Victor Bazarov wrote:
> Erik Wikstr�m wrote: >> On 2007-10-18 20:19, Donos wrote: >>> 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. > > 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. -- Erik Wikström |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Erik Wikström wrote:
> On 2007-10-18 21:06, Victor Bazarov wrote: >> Erik Wikstr�m wrote: >>> On 2007-10-18 20:19, Donos wrote: >>>> 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. >> 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. > You've got a lot more patience than me, alas. |
|
![]() |
| Outils de la discussion | |
|
|