home *** CD-ROM | disk | FTP | other *** search
- Unit Lists; { Example Doubly-Linked List Declarations }
- {$O+,S-}
-
- { While its VERY ineffecient to use the List for Integers,
- I will do so here anyway since this is only an example Unit
- intended to demonstrate the declaration of application-level
- versions of the List. }
-
- { NOTE: Lists are "Indexed" from 1 to CurrentLength }
- { CurrentLength = 0 equals Empty List }
-
- INTERFACE
-
- Uses GenList;
-
- (*
- All Lists inherit the following methods:
-
- Procedure Create;
- Procedure Destroy;
-
- Function CurrentLength : LongInt;
- Function ElemSize : Word;
- Function Node_N (N : LongInt) : D_Ptr; {See DoubLink}
-
- Procedure ReWind;
- Procedure Delete (N : LongInt); {delete Nth element}
- *)
-
- { The particular list must re-define the following methods to
- regain type-checking. }
-
- Type IntList = Object (List)
-
- Procedure Init;
-
- Procedure Append (Var I : Integer);
-
- Function GetElement_N (N : LongInt) : Integer;
- {would need to be a procedure for records and objects}
-
- Procedure ReSetElement_N (I : Integer; N : LongInt);
-
- Procedure InsertAfter_N (I : Integer; N : LongInt);
-
- Procedure Copy (From : IntList);
-
- End;
-
- IMPLEMENTATION
-
- Procedure IntList.Init;
- Begin
- List.Init (SizeOf(Integer))
- End;
-
- Procedure IntList.Append (Var I : Integer);
- Var
- J : Integer;
- Begin
- J := I;
- List.Append (J,SizeOf(Integer))
- End;
-
- Function IntList.GetElement_N (N : LongInt) : Integer;
- Var
- J : Integer;
- Begin
- List.GetElement_N (J,N,SizeOf(Integer));
- GetElement_N := J
- End;
-
- Procedure IntList.ReSetElement_N (I : Integer; N : LongInt);
- Var
- J : Integer;
- Begin
- J := I;
- List.ReSetElement_N (J,N,SizeOf(Integer))
- End;
-
- Procedure IntList.InsertAfter_N (I : Integer; N : LongInt);
- Var
- J : Integer;
- Begin
- J := I;
- List.InsertAfter_N (J,N,SizeOf(Integer))
- End;
-
- Procedure IntList.Copy (From : IntList);
- Begin
- List.Copy (From)
- End;
-
- BEGIN
- END.