mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 13:19:12 +02:00
* Patch from Serge Anvarov with some optimizations (bug ID 36143)
git-svn-id: trunk@43155 -
This commit is contained in:
parent
e67989a8e8
commit
c6d8bd73f7
@ -242,7 +242,7 @@ Type
|
|||||||
function Add(Item: Pointer): Integer; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
function Add(Item: Pointer): Integer; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
procedure Delete(Index: Integer); {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
procedure Delete(Index: Integer); {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
||||||
class procedure Error(const Msg: string; Data: PtrInt);
|
class procedure Error(const Msg: string; Data: PtrInt); static;
|
||||||
procedure Exchange(Index1, Index2: Integer);
|
procedure Exchange(Index1, Index2: Integer);
|
||||||
function Expand: TFPList; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
function Expand: TFPList; {$ifdef CLASSESINLINE} inline; {$endif CLASSESINLINE}
|
||||||
function Extract(Item: Pointer): Pointer;
|
function Extract(Item: Pointer): Pointer;
|
||||||
@ -288,15 +288,9 @@ Type
|
|||||||
TListNotification = (lnAdded, lnExtracted, lnDeleted);
|
TListNotification = (lnAdded, lnExtracted, lnDeleted);
|
||||||
TList = class;
|
TList = class;
|
||||||
|
|
||||||
TListEnumerator = class
|
TListEnumerator = class(TFPListEnumerator)
|
||||||
private
|
|
||||||
FList: TList;
|
|
||||||
FPosition: Integer;
|
|
||||||
public
|
public
|
||||||
constructor Create(AList: TList);
|
constructor Create(AList: TList);
|
||||||
function GetCurrent: Pointer;
|
|
||||||
function MoveNext: Boolean;
|
|
||||||
property Current: Pointer read GetCurrent;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TList = class(TObject,IFPObserved)
|
TList = class(TObject,IFPObserved)
|
||||||
@ -312,15 +306,15 @@ Type
|
|||||||
procedure DoOr(ListA, ListB : TList);
|
procedure DoOr(ListA, ListB : TList);
|
||||||
procedure DoXOr(ListA, ListB : TList);
|
procedure DoXOr(ListA, ListB : TList);
|
||||||
protected
|
protected
|
||||||
function Get(Index: Integer): Pointer;
|
function Get(Index: Integer): Pointer; inline;
|
||||||
procedure Grow; virtual;
|
procedure Grow; virtual;
|
||||||
procedure Put(Index: Integer; Item: Pointer);
|
procedure Put(Index: Integer; Item: Pointer);
|
||||||
procedure Notify(Ptr: Pointer; Action: TListNotification); virtual;
|
procedure Notify(Ptr: Pointer; Action: TListNotification); virtual;
|
||||||
procedure SetCapacity(NewCapacity: Integer);
|
procedure SetCapacity(NewCapacity: Integer); inline;
|
||||||
function GetCapacity: integer;
|
function GetCapacity: Integer; inline;
|
||||||
procedure SetCount(NewCount: Integer);
|
procedure SetCount(NewCount: Integer);
|
||||||
function GetCount: integer;
|
function GetCount: Integer; inline;
|
||||||
function GetList: PPointerList;
|
function GetList: PPointerList; inline;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -335,19 +329,19 @@ Type
|
|||||||
procedure Exchange(Index1, Index2: Integer);
|
procedure Exchange(Index1, Index2: Integer);
|
||||||
function Expand: TList;
|
function Expand: TList;
|
||||||
function Extract(item: Pointer): Pointer;
|
function Extract(item: Pointer): Pointer;
|
||||||
function First: Pointer;
|
function First: Pointer; inline;
|
||||||
function GetEnumerator: TListEnumerator;
|
function GetEnumerator: TListEnumerator;
|
||||||
function IndexOf(Item: Pointer): Integer;
|
function IndexOf(Item: Pointer): Integer; inline;
|
||||||
procedure Insert(Index: Integer; Item: Pointer);
|
procedure Insert(Index: Integer; Item: Pointer);
|
||||||
function Last: Pointer;
|
function Last: Pointer; inline;
|
||||||
procedure Move(CurIndex, NewIndex: Integer);
|
procedure Move(CurIndex, NewIndex: Integer); inline;
|
||||||
procedure Assign (ListA: TList; AOperator: TListAssignOp=laCopy; ListB: TList=nil);
|
procedure Assign (ListA: TList; AOperator: TListAssignOp=laCopy; ListB: TList=nil);
|
||||||
function Remove(Item: Pointer): Integer;
|
function Remove(Item: Pointer): Integer;
|
||||||
procedure Pack;
|
procedure Pack; inline;
|
||||||
procedure Sort(Compare: TListSortCompare);
|
procedure Sort(Compare: TListSortCompare); inline;
|
||||||
procedure Sort(Compare: TListSortCompare; SortingAlgorithm: PSortingAlgorithm);
|
procedure Sort(Compare: TListSortCompare; SortingAlgorithm: PSortingAlgorithm); inline;
|
||||||
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer);
|
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer); inline;
|
||||||
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer; SortingAlgorithm: PSortingAlgorithm);
|
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer; SortingAlgorithm: PSortingAlgorithm); inline;
|
||||||
property Capacity: Integer read GetCapacity write SetCapacity;
|
property Capacity: Integer read GetCapacity write SetCapacity;
|
||||||
property Count: Integer read GetCount write SetCount;
|
property Count: Integer read GetCount write SetCount;
|
||||||
property Items[Index: Integer]: Pointer read Get write Put; default;
|
property Items[Index: Integer]: Pointer read Get write Put; default;
|
||||||
|
@ -140,7 +140,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
SetCount(0);
|
SetCount(0);
|
||||||
SetCapacity(0);
|
SetCapacity(0);
|
||||||
FList := nil;
|
// FList := nil; // Already set by SetCapacity
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -535,21 +535,9 @@ end;
|
|||||||
|
|
||||||
constructor TListEnumerator.Create(AList: TList);
|
constructor TListEnumerator.Create(AList: TList);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create(AList.FList);
|
||||||
FList := AList;
|
|
||||||
FPosition := -1;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListEnumerator.GetCurrent: Pointer;
|
|
||||||
begin
|
|
||||||
Result := FList[FPosition];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TListEnumerator.MoveNext: Boolean;
|
|
||||||
begin
|
|
||||||
Inc(FPosition);
|
|
||||||
Result := FPosition < FList.Count;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
{* TList *}
|
{* TList *}
|
||||||
|
Loading…
Reference in New Issue
Block a user