Queue

Queue
A queue is a linked list that's elements can only be removed from the top and new elements can only be added to the end. Think of it like waiting in line at the movies. They are most often seen in servers that serve multiple clients. There are many classes in java's util library that implement the Queue interface. In C++ its best to make your own to fit your needs.

code format="cpp"
 * 1) include
 * 2) include

struct node{ char *info; node *next; node(char *i){ info = i;       next = NULL; } };

node *end, *start;

void add(node *n){ if(start == NULL){ end = start = n;       return; }   end->next = n;    end = n; }

node *take{ if(start == NULL) return NULL; node *tmp; tmp = start; start = start->next; return tmp; }

int main{ end = start = NULL;

add(new node("tyler")); add(new node("chris")); add(new node("matt")); add(new node("richard"));

node *tmp = take; while(tmp){ printf("%s\n", tmp->info); tmp = take; } code