问一下,有没有一个类,控制循环的,比如一个类,它的值只有 0、1、2,当它的值为2时,加1后的结果为0。
或者可以通过自定义类型的方式得到这种类型?
或者可以通过自定义类型的方式得到这种类型?
解决方案 »
- 求 delphix 的详细开发教程 和 delphix 详细 3D 入门教程!!!!!!!!1!急!!!!!!!!!!!!!!!
- 信息对话框
- 一个关于COMPUTE BY 子句的使用问题
- 请问我这段代码接受网络数据,有什么毛病,总出现地址访问错误
- 有谁知道Excel的函数中产生一个随机数的随机函数是什么?
- 数据库应用程序打包的问题!
- 分布式程序开发的问题?如何提交主从表数据(从表的)UP有分
- delphi中获得当前系统日期是什么函数?
- 请问如何将类似于¥1,049,406.06的小写金额转换为大写?算法如何?请附上源代码!
- 装rxlib2.75时遇到的问题.
- 以下线程中私有变量该怎样去赋值?请高手赐教,在线等!!
- 急急急!!!!!!请大家快来帮帮我 关于ADOCommand的插入问题
TCircleQueue = class
private
FData: Array of Pointer;
FLength: Integer;
FIndex: Integer;
procedure SetLength(const Value: Integer);
function Next: Integer;
function Previous: Integer;
function GetItem: Pointer;
procedure SetItem(const Value: Pointer);
protected
property Item: Pointer read GetItem write SetItem;
public
property Size: Integer read FLength write SetLength;
property Index: Integer read FIndex;
procedure Queue(const Value: Pointer);
function Dequeue: Pointer;
constructor Create;
destructor Destroy; override;
end;
implementation
constructor TCircleQueue.Create;
begin
FData := TList.Create;
SetLength(2);
end;destructor TCircleQueue.Destroy;
begin
FIndex := -1;
FLength := -1;
SetLength(FData,0);
Inherited;
end;function TCircleQueue.Next: Integer;
begin
FIndex := (FIndex + 1) mod FLength;
Result := FIndex;
end;function TCircleQueue.Previous: Integer;
begin
FIndex := (FIndex + FLength - 1) mod FLength;
Result := FIndex;
end;function TCircleQueue.GetItem: Pointer;
begin
Result := FData[FIndex];
end;procedure TCircleQueue.SetItem(const Value: Pointer);
begin
FData[FIndex] := Value;
end;function TCircleQueue.Dequeue: Pointer;
begin
Result := Item;
Next;
end;procedure TCircleQueue.Queue(const Value: Pointer);
begin
Previous;
Item := Value;
end;procedure TCircleQueue.SetLength(const Value: Integer);
begin
SetLength(FData,Value);
FLength := Value;
if FIndex > FLength then
FIndex := 0;
end;