Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as D by Minthos ( 15 years ago )
class queue{
 struct element{
  void* data;
  element* next;
 }

 element* head;
 element* tail;

 this(){
  head = null;
  tail = null;
 }

 void push(void* data){
  element* e = new element;
  e.next = null;
  if(tail){
   tail.next = e;
  } else {
   head = e;
  }
 }

 void* pop(){
  element *ret = head;
  if(head){
   head = head.next;
  }
  return ret;
 }
}

 

Revise this Paste

Your Name: Code Language: