diff --git a/fcl/inc/lists.inc b/fcl/inc/lists.inc index e643f71f25..16354bf4dc 100644 --- a/fcl/inc/lists.inc +++ b/fcl/inc/lists.inc @@ -25,6 +25,9 @@ function TList.Get(Index: Integer): Pointer; begin + If (Index<0) or (Index>Count) then + Runerror (255); + Result:=FList^[Index]; end; @@ -32,6 +35,7 @@ end; procedure TList.Grow; begin + end; @@ -39,6 +43,11 @@ end; procedure TList.Put(Index: Integer; Item: Pointer); begin + if Index<0 then + Runerror(255) + While Index>Capacity do Grow; + Flist[I^ndex]:=Item; + If Index>Count then Count:=Index; end; @@ -53,6 +62,16 @@ end; procedure TList.SetCount(NewCount: Integer); begin + If NewCount<0 then + RunError(255); + If NewCountCapacity do Grow; + FillByte (Flist[count],(Newcount-Count)*SizeOF(Pointer),0); + FCount:=Newcount; + end; end; @@ -68,7 +87,7 @@ end; Function TList.Add(Item: Pointer): Integer; begin -// Self.Insert (Count,Item); + Self.Insert (Count,Item); end; @@ -76,6 +95,13 @@ end; Procedure TList.Clear; begin + If Assigned(FList) then + begin + FreeMem (Flist,FCapacity); + FList:=Nil; + FCapacity:=nil; + FCount:=Nil; + end; end; @@ -93,8 +119,12 @@ end; procedure TList.Exchange(Index1, Index2: Integer); +var Temp1,Temp2 : Pointer; begin + Temp:=FList[Index1]; + Items[Index1]:=Items[Index2]; + Items[Index2]:=Temp; end; @@ -103,19 +133,33 @@ function TList.Expand: TList; begin + If Count=FCapacity then Grow; end; function TList.First: Pointer; +Var I : longint; + begin + I:=0; + Result:=Nil; + While (IItem) do Inc(I); + If Flist[I]=Item then Result:=I; end; @@ -123,13 +167,25 @@ end; procedure TList.Insert(Index: Integer; Item: Pointer); begin + If (Index<0) then + RunError(255); + While Index+1>Capacity do Grow; + If Index-1) and (FList[I]=Nil) dec Inc(i); + if I>-1 then Result:=FList[I]; end; @@ -142,11 +198,18 @@ end; function TList.Remove(Item: Pointer): Integer; begin + If (Index<0) or (Index>Count-1) then + RunError(255); + While Index+1>Capacity do Grow; + System.Move (Flist[Index],Flist[Index+1],(Count-Index)*SizeOf(Pointer)); + Item[Index]:=Item; end; procedure TList.Pack; + + begin end; @@ -211,7 +274,10 @@ begin end; { $Log$ - Revision 1.1 1998-05-04 14:30:12 michael + Revision 1.2 1998-05-04 15:54:07 michael + + Partial implementation of TList + + Revision 1.1 1998/05/04 14:30:12 michael * Split file according to Class; implemented dummys for all methods, so unit compiles. }