📄 fifo.pas
字号:
{
FIFO.PAS
Unit for a fifo.
(C) C. Valens, <c.valens@mindless.com>
Created : 01/05/1998
Last update: 03/05/1998
}
unit fifo;
{******************************************************}
{* INTERFACE *}
{******************************************************}
interface
type
ezw_element = record
x, y, code: integer;
end;
var
fifo_empty: boolean;
procedure put_in_fifo(d: ezw_element);
procedure get_from_fifo(var d: ezw_element);
procedure destroy_fifo;
{******************************************************}
{* IMPLEMENTATION *}
{******************************************************}
implementation
type
fifo_element_ptr = ^fifo_element;
fifo_element = record
data: ezw_element;
previous: fifo_element_ptr;
end;
var
fifo_first, fifo_last: fifo_element_ptr;
procedure put_in_fifo(d: ezw_element);
var
p: fifo_element_ptr;
begin
GetMem(p,SizeOf(fifo_element));
if p<>NIL then begin
p^.data := d;
p^.previous := NIL;
if fifo_last<>NIL then fifo_last^.previous := p;
fifo_last := p;
if fifo_first=NIL then fifo_first := p;
fifo_empty := FALSE;
end;
end;
procedure get_from_fifo(var d: ezw_element);
var
p: fifo_element_ptr;
begin
p := fifo_first;
if p<>NIL then begin
d := p^.data;
fifo_first := p^.previous;
FreeMem(p,SizeOf(fifo_element));
end
else begin
fifo_last := NIL;
fifo_empty := TRUE;
end;
end;
procedure destroy_fifo;
var
p: fifo_element_ptr;
begin
while fifo_first<>NIL do begin
p := fifo_first;
fifo_first := p^.previous;
FreeMem(p,SizeOf(fifo_element));
end;
fifo_last := NIL;
fifo_empty := TRUE;
end;
begin
fifo_first := NIL;
fifo_last := NIL;
fifo_empty := TRUE;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -