home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / arrays / generics / genlist / lists.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-24  |  2.2 KB  |  95 lines

  1. Unit Lists; { Example Doubly-Linked List Declarations }
  2. {$O+,S-}
  3.  
  4. { While its VERY ineffecient to use the List for Integers,
  5.   I will do so here anyway since this is only an example Unit
  6.   intended to demonstrate the declaration of application-level
  7.   versions of the List. }
  8.  
  9. { NOTE: Lists are "Indexed" from 1 to CurrentLength }
  10. {       CurrentLength = 0 equals Empty List         }
  11.  
  12. INTERFACE
  13.  
  14. Uses GenList;
  15.  
  16. (*
  17.   All Lists inherit the following methods:
  18.  
  19.                         Procedure Create;
  20.                         Procedure Destroy;
  21.  
  22.                         Function CurrentLength : LongInt;
  23.                         Function ElemSize : Word;
  24.                         Function Node_N (N : LongInt) : D_Ptr; {See DoubLink}
  25.  
  26.                         Procedure ReWind;
  27.                         Procedure Delete (N : LongInt); {delete Nth element}
  28. *)
  29.  
  30. { The particular list must re-define the following methods to
  31.   regain type-checking. }
  32.  
  33. Type IntList = Object (List)
  34.  
  35.                  Procedure Init;
  36.  
  37.                  Procedure Append (Var I : Integer);
  38.  
  39.                  Function GetElement_N (N : LongInt) : Integer;
  40.                    {would need to be a procedure for records and objects}
  41.  
  42.                  Procedure ReSetElement_N (I : Integer; N : LongInt);
  43.  
  44.                  Procedure InsertAfter_N (I : Integer; N : LongInt);
  45.  
  46.                  Procedure Copy (From : IntList);
  47.  
  48.                End;
  49.  
  50. IMPLEMENTATION
  51.  
  52. Procedure IntList.Init;
  53. Begin
  54.   List.Init (SizeOf(Integer))
  55. End;
  56.  
  57. Procedure IntList.Append (Var I : Integer);
  58. Var
  59.   J : Integer;
  60. Begin
  61.   J := I;
  62.   List.Append (J,SizeOf(Integer))
  63. End;
  64.  
  65. Function IntList.GetElement_N (N : LongInt) : Integer;
  66. Var
  67.   J : Integer;
  68. Begin
  69.   List.GetElement_N (J,N,SizeOf(Integer));
  70.   GetElement_N := J
  71. End;
  72.  
  73. Procedure IntList.ReSetElement_N (I : Integer; N : LongInt);
  74. Var
  75.   J : Integer;
  76. Begin
  77.   J := I;
  78.   List.ReSetElement_N (J,N,SizeOf(Integer))
  79. End;
  80.  
  81. Procedure IntList.InsertAfter_N (I : Integer; N : LongInt);
  82. Var
  83.   J : Integer;
  84. Begin
  85.   J := I;
  86.   List.InsertAfter_N (J,N,SizeOf(Integer))
  87. End;
  88.  
  89. Procedure IntList.Copy (From : IntList);
  90. Begin
  91.   List.Copy (From)
  92. End;
  93.  
  94. BEGIN
  95. END.