Re: Linked list storing a queue
From: Alf P. Steinbach (alfps_at_start.no)
Date: 08/31/04
- Next message: Joe Harris: "Re: finding an index in an STL vector<>"
- Previous message: Paul Mensonides: "Re: Cpp Considered Harmful"
- In reply to: Kay: "Linked list storing a queue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 03:46:32 GMT
* 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?
- Next message: Joe Harris: "Re: finding an index in an STL vector<>"
- Previous message: Paul Mensonides: "Re: Cpp Considered Harmful"
- In reply to: Kay: "Linked list storing a queue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|