Linked lisd storing a queue

K

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 ?
 
T

Thomas Matthews

Kay said:
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 ?

Why should we bother helping you?
After all, it appears that you haven't read or
applied any of the information in the replies
to your posts in various newsgroups.

Post your C language code that you are having problems
with. Indicate where the problem is. Also indicate
the actual behavior versus the expected behavior.

I don't see why you need a queue in a node of a list.
Generally, if a name in a list is duplicated, the
quantity variable in the list is incremented. This
saves memory space and time as well.

struct StringType;

struct node
{
struct StringType name;
unsigned int num_duplicates;
};

If you _really_ need queues for each node:
struct Queue;
struct StringType;

struct node
{
struct StringType name;
struct Queue q;
};

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
M

Malcolm

Kay said:
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 ?
Is English not your first language? Unfortunately the question doesn't make
complete sense.
You can use a linked list as a queue, though it is not a particularly
efficient structure for doing so. Make it a doubly-linked list and store
pointers to the head and tail.
I think that what you need to do is iterate over the list, seeing if you
have a duplicate. If you do you take appropraiate action. New entries are
inserted at the tail of the list, and presmably you have a "reader" function
that consumes the head of the list.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top