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
Post a Comment