structure pointer_t {ptr: pointer to node_t, count: unsigned integer}
  structure node_t {value: data type, next: pointer_t}
  structure queue_t {Head: pointer_t, Tail: pointer_t}
  
  initialize(Q: pointer to queue_t)
     node = new_node()		
     node->next.ptr = NULL	
     Q->Head.ptr = Q->Tail.ptr = node	
  
  enqueue(Q: pointer to queue_t, value: data type)
   E1:   node = new_node()	
   E2:   node->value = value	
   E3:   node->next.ptr = NULL	
   E4:   loop			
   E5:      tail = Q->Tail	
   E6:      next = tail.ptr->next
   E7:      if tail == Q->Tail	
   E8:         if next.ptr == NULL
   E9:            if CAS(&tail.ptr->next, next, <node, next.count+1>)
  E10:               break	
  E11:            endif
  E12:         else	
  E13:            CAS(&Q->Tail, tail, <next.ptr, tail.count+1>)
  E14:         endif
  E15:      endif
  E16:   endloop
  E17:   CAS(&Q->Tail, tail, <node, tail.count+1>)
  
  dequeue(Q: pointer to queue_t, pvalue: pointer to data type): boolean
   D1:   loop			    
   D2:      head = Q->Head	   
   D3:      tail = Q->Tail	    
   D4:      next = head.ptr->next  
   D5:      if head == Q->Head	    
   D6:         if head.ptr == tail.ptr 
   D7:            if next.ptr == NULL  
   D8:               return FALSE      
   D9:            endif
  D10:            CAS(&Q->Tail, tail, <next.ptr, tail.count+1>)
  D11:         else		   
  D12:            *pvalue = next.ptr->value
  D13:            if CAS(&Q->Head, head, <next.ptr, head.count+1>)
  D14:               break           
  D15:            endif
  D16:         endif
  D17:      endif
  D18:   endloop
  D19:   free(head.ptr)		  
  D20:   return TRUE