Linked list storing a queue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kay

    #1

    Linked list storing a queue

    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 ?

  • Alf P. Steinbach

    #2
    Re: Linked list storing a queue

    * Kay:[color=blue]
    > 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 ?[/color]

    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?

    Comment

    Working...