unit MyQueue; interface type TList = ^TElem; TElem = record INFO: char; NEXT : TList end; TQueue = class private head:TList; tail:TList; public procedure Init (var Q:TQueue); Function Empty(Q:TQueue):boolean; Procedure Push(var q:TQueue; e:Char); Function Pop(var q:TQueue):Char; end; implementation procedure TQueue.Init (var Q:TQueue); begin q.head:=nil end; Function TQueue.Empty(Q:TQueue):boolean; begin Empty:=(q.head=nil) end; Procedure TQueue.Push(var q:TQueue; e: Char); var z:Tlist; begin new(z); z^.info:=E; z^.next:=nil; If Empty(q) then q.head:=z else q.tail^.next:=z; q.tail:=z end; Function TQueue.Pop(var q:TQueue):Char; var z:TList; begin z:=q.head; q.head:=z^.next; Pop:=Z^.info; dispose(z) end; end.