Linked list storing a queue

Discussion in 'C++' started by Kay, Aug 31, 2004.

  1. Kay

    Kay Guest

    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 ?
     
    Kay, Aug 31, 2004
    #1
    1. Advertising

  2. * 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?
     
    Alf P. Steinbach, Aug 31, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    691
    Russell Warren
    Jun 27, 2006
  2. Kay

    Linked lisd storing a queue

    Kay, Aug 31, 2004, in forum: C Programming
    Replies:
    2
    Views:
    280
    Malcolm
    Aug 31, 2004
  3. fool
    Replies:
    14
    Views:
    519
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    679
    John Carson
    Oct 2, 2006
  5. Kris
    Replies:
    0
    Views:
    494
Loading...

Share This Page