mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 09:38:12 +02:00
lazutils: fixed TAVLTree using fnodemgr
git-svn-id: trunk@54538 -
This commit is contained in:
parent
7fa04aed29
commit
9424db5d62
@ -38,6 +38,7 @@ type
|
||||
procedure FreeAndDelete(ANode: TAVLTreeNode); override;
|
||||
property OwnsObjects: boolean read FOwnsObjects write FOwnsObjects;
|
||||
end;
|
||||
TAvgLvlTreeClass = class of TAvgLvlTree;
|
||||
|
||||
{ TIndexedAVLTreeNode }
|
||||
|
||||
@ -48,7 +49,7 @@ type
|
||||
|
||||
{ TIndexedAVLTree }
|
||||
|
||||
TIndexedAVLTree = class(TAvlTree)
|
||||
TIndexedAVLTree = class(TAvgLvlTree)
|
||||
private
|
||||
function GetItems(Index: SizeInt): Pointer; inline;
|
||||
protected
|
||||
|
@ -244,7 +244,7 @@ end;
|
||||
|
||||
function TAVLTree.Add(Data: Pointer): TAVLTreeNode;
|
||||
begin
|
||||
Result:=fNodeMgr.NewNode;
|
||||
Result:=NewNode;
|
||||
Result.Data:=Data;
|
||||
Add(Result);
|
||||
end;
|
||||
@ -292,16 +292,16 @@ end;
|
||||
|
||||
function TAVLTree.NewNode: TAVLTreeNode;
|
||||
begin
|
||||
if LazNodeMemManager<>nil then
|
||||
Result:=LazNodeMemManager.NewNode
|
||||
if fNodeMgr<>nil then
|
||||
Result:=fNodeMgr.NewNode
|
||||
else
|
||||
Result:=NodeClass.Create;
|
||||
end;
|
||||
|
||||
procedure TAVLTree.DisposeNode(ANode: TAVLTreeNode);
|
||||
begin
|
||||
if LazNodeMemManager<>nil then
|
||||
LazNodeMemManager.DisposeNode(ANode)
|
||||
if fNodeMgr<>nil then
|
||||
fNodeMgr.DisposeNode(ANode)
|
||||
else
|
||||
ANode.Free;
|
||||
end;
|
||||
@ -628,7 +628,7 @@ procedure TAVLTree.Clear;
|
||||
if ANode.Left<>nil then DeleteNode(ANode.Left);
|
||||
if ANode.Right<>nil then DeleteNode(ANode.Right);
|
||||
end;
|
||||
fNodeMgr.DisposeNode(ANode);
|
||||
DisposeNode(ANode);
|
||||
end;
|
||||
|
||||
// Clear
|
||||
@ -1326,6 +1326,9 @@ procedure TAVLTree.SetNodeManager(NewMgr: TBaseAVLTreeNodeManager;
|
||||
AutoFree: boolean);
|
||||
// only allowed just after create.
|
||||
begin
|
||||
if fNodeMgr=NewMgr then exit;
|
||||
if Count>0 then
|
||||
raise Exception.Create('TAVLTree.SetNodeManager');
|
||||
if fNodeMgrAutoFree then
|
||||
FreeAndNil(fNodeMgr);
|
||||
fNodeMgr:=NewMgr;
|
||||
|
Loading…
Reference in New Issue
Block a user