home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / zkuste / delphi / WhiteAnts / PROGRESS.ZIP / INTLISTS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-10  |  4.8 KB  |  148 lines

  1. {
  2. +----------------------------------------------------------------------------+
  3. |                                      ⌐  ⌐                                  |
  4. |                                    ⌐⌐ ⌐ ⌐ ⌐                                |
  5. |                                 ⌐⌐⌐ ⌐   ⌐  ⌐                               |
  6. |                                 ⌐⌐    ⌐ ⌐   ⌐                              |
  7. |                  ⌐             ⌐⌐     ⌐  ⌐                                 |
  8. |                 ⌐ ⌐            ⌐⌐⌐    ⌐⌐  ⌐                                |
  9. |             ⌐⌐  ⌐  ⌐      ⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐  ⌐                                    |
  10. |            ⌐  ⌐⌐  ⌐⌐      ⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐                                  |
  11. |            ⌐ ⌐⌐⌐ ⌐⌐⌐⌐⌐⌐ ⌐⌐⌐ ⌐   ⌐⌐⌐⌐⌐⌐⌐⌐                                   |
  12. |           ⌐ ⌐⌐ ⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐ ⌐   ⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐      Copyright ⌐ 1996-1997 by:  |
  13. |           ⌐ ⌐⌐⌐⌐⌐⌐ ⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐⌐  ⌐ ⌐⌐⌐⌐⌐ ⌐⌐                                 |
  14. |          ⌐ ⌐⌐⌐⌐⌐⌐⌐   ⌐⌐⌐⌐⌐ ⌐⌐⌐⌐    ⌐⌐ ⌐⌐ ⌐      WHITE ANTS SYSTEMHOUSE BV  |
  15. |         ⌐  ⌐⌐⌐⌐⌐⌐⌐ ⌐⌐⌐ ⌐⌐⌐ ⌐⌐ ⌐       ⌐⌐⌐⌐      Geleen 12                  |
  16. |         ⌐ ⌐⌐⌐⌐⌐⌐⌐    ⌐   ⌐⌐   ⌐⌐⌐       ⌐       8032 GB Zwolle             |
  17. |           ⌐⌐⌐⌐⌐⌐     ⌐            ⌐ ⌐           Netherlands                |
  18. |      ⌐⌐⌐  ⌐⌐⌐⌐⌐      ⌐     ⌐⌐     ⌐  ⌐                                     |
  19. |            ⌐⌐       ⌐              ⌐  ⌐⌐⌐ ⌐     Tel. +31 38 453 86 31      |
  20. |      ⌐              ⌐              ⌐            Fax. +31 38 453 41 22      |
  21. |      ⌐             ⌐               ⌐⌐                                      |
  22. |    ⌐              ⌐                  ⌐⌐         www.whiteants.com          |
  23. |  ⌐⌐              ⌐                     ⌐ ⌐      support@whiteants.com      |
  24. |                 ⌐                                                          |
  25. +----------------------------------------------------------------------------+
  26.   file     : IntLists
  27.   version  : 1.0
  28.   comment  : TIntList is an dynamic array of integers using a TList to store
  29.              the integers
  30.   author   : G. Beuze
  31.   compiler : Delphi 1.0
  32. +----------------------------------------------------------------------------+
  33. | DISCLAIMER:                                                                |
  34. | THIS SOURCE IS FREEWARE. YOU ARE ALLOWED TO USE IT IN YOUR OWN PROJECTS    |
  35. | WITHOUT ANY RESTRICTIONS. YOU ARE NOT ALLOWED TO SELL THE SOURCE CODE.     |
  36. | THERE IS NO WARRANTY AT ALL - YOU USE IT ON YOUR OWN RISC. WHITE ANTS DOES |
  37. | NOT ASSUME ANY RESPONSIBILITY FOR ANY DAMAGE OR ANY LOSS OF TIME OR MONEY  |
  38. | DUE THE USE OF ANY PART OF THIS SOURCE CODE.                               |
  39. +----------------------------------------------------------------------------+
  40. }
  41. unit IntLists;
  42.  
  43. interface
  44.  
  45. uses Classes;
  46.  
  47. type
  48.   TIntList = class(TObject)
  49.   private
  50.     FList: TList;
  51.   protected
  52.     function Get(Index: Integer): LongInt;
  53.     function GetCount: Integer;
  54.     procedure Put(Index: Integer; Item: LongInt);
  55.     procedure SetCount(NewCount: Integer);
  56.   public
  57.     constructor Create;
  58.     destructor Destroy; override;
  59.     function Add(Item: LongInt): Integer;
  60.     procedure Clear;
  61.     procedure Delete(Index: Integer);
  62.     procedure Exchange(Index1, Index2: Integer);
  63.     function IndexOf(Item: LongInt): Integer;
  64.     procedure Insert(Index: Integer; Item: LongInt);
  65.     procedure Move(CurIndex, NewIndex: Integer);
  66.     function Remove(Item: LongInt): Integer;
  67.     property Count: Integer read GetCount write SetCount;
  68.     property Items[Index: Integer]: LongInt read Get write Put; default;
  69.   end;
  70.  
  71.  
  72. implementation
  73.  
  74. { TIntList }
  75.  
  76. constructor TIntList.Create;
  77. begin
  78.   inherited Create;
  79.   FList := TList.Create;
  80. end;
  81.  
  82. destructor TIntList.Destroy;
  83. begin
  84.   FList.Free;
  85. end;
  86.  
  87. function TIntList.Add(Item: LongInt): Integer;
  88. begin
  89.   FList.Add(Pointer(Item));
  90. end;
  91.  
  92. procedure TIntList.Clear;
  93. begin
  94.   FList.Clear;
  95. end;
  96.  
  97. procedure TIntList.Delete(Index: Integer);
  98. begin
  99.   FList.Delete(Index);
  100. end;
  101.  
  102. procedure TIntList.Exchange(Index1, Index2: Integer);
  103. begin
  104.   FList.Exchange(Index1, Index2);
  105. end;
  106.  
  107. function TIntList.Get(Index: Integer): LongInt;
  108. begin
  109.   Result := LongInt(FList[Index]);
  110. end;
  111.  
  112. function TIntList.GetCount: Integer;
  113. begin
  114.   Result := FList.Count;
  115. end;
  116.  
  117. function TIntList.IndexOf(Item: LongInt): Integer;
  118. begin
  119.   Result := FList.IndexOf(Pointer(Item));
  120. end;
  121.  
  122. procedure TIntList.Insert(Index: Integer; Item: LongInt);
  123. begin
  124.   FList.Insert(Index, Pointer(Item));
  125. end;
  126.  
  127. procedure TIntList.Move(CurIndex, NewIndex: Integer);
  128. begin
  129.   FList.Move(CurIndex, NewIndex);
  130. end;
  131.  
  132. procedure TIntList.Put(Index: Integer; Item: LongInt);
  133. begin
  134.   FList[Index] := Pointer(Item);
  135. end;
  136.  
  137. function TIntList.Remove(Item: LongInt): Integer;
  138. begin
  139.   Result := FList.Remove(Pointer(Item));
  140. end;
  141.  
  142. procedure TIntList.SetCount(NewCount: Integer);
  143. begin
  144.   FList.Count := NewCount;
  145. end;
  146.  
  147. end.
  148.