469,925 Members | 1,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

Linked list storing a queue

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
1 1943
* 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.

Similar topics

2 posts views Thread by Kay | last post: by
2 posts views Thread by Kay | last post: by
4 posts views Thread by dssuresh6 | last post: by
4 posts views Thread by JS | last post: by
57 posts views Thread by Xarky | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.