Linked list storing a queue

K

Kay

A linked list is storing several names. I want to make a queue if I
input a name that is same as the linked list. How to make each node of a
linked list storing a queue that are different with each other node, do
I need to add one more item in the ListNode OR I only call the queue
insert function to do it ?
 
A

Alf P. Steinbach

* Kay:
A linked list is storing several names. I want to make a queue if I
input a name that is same as the linked list. How to make each node of a
linked list storing a queue that are different with each other node, do
I need to add one more item in the ListNode OR I only call the queue
insert function to do it ?

Are you sure you really want a _list_?

A std::map seems more appropriate from what you write.

But assuming a list is indeed The Thing,

class Data...

class NameAndDataList
{
private:
struct NameAndData
{
std::string name;
Data data;
NameAndData( std::string const& s, Data const& d )
: name( s ), data( d )
{}
};

std::list< std::queue< NameAndData > > myList;

public:
...

void insert( std::string const& name; Data const& data )
{
// insertion code goes here.
}
};
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top