mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 16:31:40 +02:00
implemented editing dependencies
git-svn-id: trunk@3410 -
This commit is contained in:
parent
8f9ea479eb
commit
a9ebfbffec
@ -63,6 +63,9 @@ type
|
||||
function FindKey(Key: Pointer;
|
||||
OnCompareKeyWithData: TListSortCompare): TAVLTreeNode;
|
||||
function FindNearest(Data: Pointer): TAVLTreeNode;
|
||||
function FindPointer(Data: Pointer): TAVLTreeNode;
|
||||
function FindLeftMost(Data: Pointer): TAVLTreeNode;
|
||||
function FindRightMost(Data: Pointer): TAVLTreeNode;
|
||||
function FindSuccessor(ANode: TAVLTreeNode): TAVLTreeNode;
|
||||
function FindPrecessor(ANode: TAVLTreeNode): TAVLTreeNode;
|
||||
function FindLowest: TAVLTreeNode;
|
||||
@ -71,6 +74,7 @@ type
|
||||
function Add(Data: Pointer): TAVLTreeNode;
|
||||
procedure Delete(ANode: TAVLTreeNode);
|
||||
procedure Remove(Data: Pointer);
|
||||
procedure RemovePointer(Data: Pointer);
|
||||
procedure MoveDataLeftMost(var ANode: TAVLTreeNode);
|
||||
procedure MoveDataRightMost(var ANode: TAVLTreeNode);
|
||||
property OnCompare: TListSortCompare read FOnCompare write SetOnCompare;
|
||||
@ -617,6 +621,15 @@ begin
|
||||
Delete(ANode);
|
||||
end;
|
||||
|
||||
procedure TAVLTree.RemovePointer(Data: Pointer);
|
||||
var
|
||||
ANode: TAVLTreeNode;
|
||||
begin
|
||||
ANode:=FindPointer(Data);
|
||||
if ANode<>nil then
|
||||
Delete(ANode);
|
||||
end;
|
||||
|
||||
destructor TAVLTree.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
@ -675,6 +688,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindPointer(Data: Pointer): TAVLTreeNode;
|
||||
begin
|
||||
Result:=FindLeftMost(Data);
|
||||
while (Result<>nil) do begin
|
||||
if Result.Data=Data then break;
|
||||
Result:=FindSuccessor(Result);
|
||||
if OnCompare(Data,Result.Data)<>0 then Result:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindLeftMost(Data: Pointer): TAVLTreeNode;
|
||||
var
|
||||
Left: TAVLTreeNode;
|
||||
begin
|
||||
Result:=Find(Data);
|
||||
while (Result<>nil) do begin
|
||||
Left:=FindPrecessor(Result);
|
||||
if (Left=nil) or (OnCompare(Data,Left.Data)<>0) then break;
|
||||
Result:=Left;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindRightMost(Data: Pointer): TAVLTreeNode;
|
||||
var
|
||||
Right: TAVLTreeNode;
|
||||
begin
|
||||
Result:=Find(Data);
|
||||
while (Result<>nil) do begin
|
||||
Right:=FindSuccessor(Result);
|
||||
if (Right=nil) or (OnCompare(Data,Right.Data)<>0) then break;
|
||||
Result:=Right;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAVLTree.FindInsertPos(Data: Pointer): TAVLTreeNode;
|
||||
var Comp: integer;
|
||||
begin
|
||||
|
@ -140,6 +140,7 @@ procedure FreeThenNil(var Obj: TObject);
|
||||
function CompareCaret(const FirstCaret, SecondCaret: TPoint): integer;
|
||||
procedure CheckList(List: TList; TestListNil, TestDoubles, TestNils: boolean);
|
||||
procedure CheckEmptyListCut(List1, List2: TList);
|
||||
function CompareBoolean(b1, b2: boolean): integer;
|
||||
|
||||
const
|
||||
{$IFDEF Win32}
|
||||
@ -613,6 +614,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
function CompareBoolean(b1, b2: boolean): integer;
|
||||
-------------------------------------------------------------------------------}
|
||||
function CompareBoolean(b1, b2: boolean): integer;
|
||||
begin
|
||||
if b1=b2 then
|
||||
Result:=0
|
||||
else if b1 then
|
||||
Result:=1
|
||||
else
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
BackupFile
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user