PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Taking values from Queue
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Taking values from Queue

Réponse
 
LinkBack Outils de la discussion
Vieux 18/10/2007, 16h30   #1
Donos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Taking values from Queue

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.

  Réponse avec citation
Vieux 18/10/2007, 17h45   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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


  Réponse avec citation
Vieux 18/10/2007, 19h19   #3
Donos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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?

  Réponse avec citation
Vieux 18/10/2007, 19h38   #4
Erik Wikström
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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
  Réponse avec citation
Vieux 18/10/2007, 20h06   #5
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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


  Réponse avec citation
Vieux 18/10/2007, 20h31   #6
Erik Wikström
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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
  Réponse avec citation
Vieux 18/10/2007, 21h47   #7
red floyd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Taking values from Queue

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.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h46.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12840 seconds with 15 queries