By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,462 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,462 IT Pros & Developers. It's quick & easy.

Linked list storing a queue

P: n/a
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 ?

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* 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.
}
};

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.