Re: Linked list storing a queue

From: Alf P. Steinbach (alfps_at_start.no)
Date: 08/31/04


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?


Relevant Pages

  • Re: Linked lisd storing a queue
    ... > A linked list is storing several names. ... I want to make a queue if I ... pointers to the head and tail. ... that consumes the head of the list. ...
    (comp.lang.c)
  • Re: type convertion
    ... > This function is loaded a txt file and add these data in a queue. ... > below) is storing an integer. ... Can it use other way to load the txt file? ... Did you not read the replies you already got? ...
    (comp.lang.cpp)
  • Re: Search Queue
    ... abcd wrote: ... And I am storing them in a Queue.Queue... ... Typically a queue only lets you put and get, ...
    (comp.lang.python)
  • Re: Multiple IP addresses and certificate "common name"
    ... Perhaps you could try to make your followups follow the Usenet ... queue because it does know how to lock files the way that Sendmail does ... main daemon to serve the individual connection, ...
    (comp.mail.sendmail)
  • Re: Wakefield Show report
    ... his explanation was that it must have been held up in a queue. ... Genuine and spam-proof addresses for Usenet: ... Email address for replies: substitute postmaster@ for tim@ ...
    (comp.sys.acorn.misc)