c++ - insert into front of queue instead of back -


for project, want insert ascii letters @ end of queue , numbers @ front of queue. know how insert things @ end of queue, stuck on latter.

here enqueue function:

void linkedqueue::enqueue(elementtype new_data) {     node *newnode = new node(new_data);     node *tempholder = head;     while (tempholder->next !=null)     {         tempholder = tempholder->next;     }     tempholder->next = newnode;     mysize ++; } 

how modify function named enqueue_front?

simple linked list modification trick.

void linkedqueue::enqueue_front(elementtype new_data) {     node *newnode = new node(new_data);     newnode->next = head;     head = newnode;         mysize ++; } 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -