|
Last change
on this file was 60, checked in by chronos, 19 months ago |
- Modified: Remove U prefix from unit names.
|
|
File size:
638 bytes
|
| Line | |
|---|
| 1 | unit Kernel.Classes;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Contnrs;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 |
|
|---|
| 10 | { TObjectQueue }
|
|---|
| 11 |
|
|---|
| 12 | TObjectQueue = class
|
|---|
| 13 | List: TObjectList;
|
|---|
| 14 | procedure Enqueue(Item: TObject);
|
|---|
| 15 | function Dequeue: TObject;
|
|---|
| 16 | constructor Create;
|
|---|
| 17 | destructor Destroy; override;
|
|---|
| 18 | end;
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | implementation
|
|---|
| 22 |
|
|---|
| 23 | { TObjectQueue }
|
|---|
| 24 |
|
|---|
| 25 | procedure TObjectQueue.Enqueue(Item: TObject);
|
|---|
| 26 | begin
|
|---|
| 27 | List.Add(Item);
|
|---|
| 28 | end;
|
|---|
| 29 |
|
|---|
| 30 | function TObjectQueue.Dequeue: TObject;
|
|---|
| 31 | begin
|
|---|
| 32 | Result := List[0];
|
|---|
| 33 | List.Delete(0);
|
|---|
| 34 | end;
|
|---|
| 35 |
|
|---|
| 36 | constructor TObjectQueue.Create;
|
|---|
| 37 | begin
|
|---|
| 38 | List := TObjectList.Create;
|
|---|
| 39 | end;
|
|---|
| 40 |
|
|---|
| 41 | destructor TObjectQueue.Destroy;
|
|---|
| 42 | begin
|
|---|
| 43 | FreeAndNil(List);
|
|---|
| 44 | inherited;
|
|---|
| 45 | end;
|
|---|
| 46 |
|
|---|
| 47 | end.
|
|---|
| 48 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.