|
@@ -113,8 +113,9 @@ type
|
|
constructor Create(AAbstractMem : TAbstractMem; const AInitialZone: TAMZone; AAllowDuplicates : Boolean; AOrder : Integer; const AOnCompareAbstractMemDataMethod: TComparison<TBTreeData>);
|
|
constructor Create(AAbstractMem : TAbstractMem; const AInitialZone: TAMZone; AAllowDuplicates : Boolean; AOrder : Integer; const AOnCompareAbstractMemDataMethod: TComparison<TBTreeData>);
|
|
procedure Add(); reintroduce;
|
|
procedure Add(); reintroduce;
|
|
procedure Delete(); reintroduce;
|
|
procedure Delete(); reintroduce;
|
|
- function FindData(const AData: TBTreeData; out APosition : TAbstractMemPosition; out AFoundData : TBTreeData) : Boolean; overload;
|
|
|
|
- function FindData(const AData: TBTreeData; out APosition : TAbstractMemPosition) : Boolean; overload;
|
|
|
|
|
|
+ function FindData(const AData: TBTreeData; out APosition : TAbstractMemPosition; var AFoundData : TBTreeData) : Boolean; overload;
|
|
|
|
+ function FindData(const AData: TBTreeData; var AFoundData : TBTreeData) : Boolean; overload;
|
|
|
|
+ function FindDataPos(const AData: TBTreeData; out APosition : TAbstractMemPosition) : Boolean;
|
|
function FindDataPrecessor(const AData : TBTreeData; var APrecessor : TBTreeData) : Boolean;
|
|
function FindDataPrecessor(const AData : TBTreeData; var APrecessor : TBTreeData) : Boolean;
|
|
function FindDataSuccessor(const AData : TBTreeData; var ASuccessor : TBTreeData) : Boolean;
|
|
function FindDataSuccessor(const AData : TBTreeData; var ASuccessor : TBTreeData) : Boolean;
|
|
function FindDataLowest(out ALowest : TBTreeData) : Boolean;
|
|
function FindDataLowest(out ALowest : TBTreeData) : Boolean;
|
|
@@ -559,9 +560,9 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TAbstractMemBTreeDataAbstract<TBTreeData>.FindData(const AData: TBTreeData;
|
|
function TAbstractMemBTreeDataAbstract<TBTreeData>.FindData(const AData: TBTreeData;
|
|
- out APosition: TAbstractMemPosition; out AFoundData : TBTreeData): Boolean;
|
|
|
|
|
|
+ out APosition: TAbstractMemPosition; var AFoundData : TBTreeData): Boolean;
|
|
begin
|
|
begin
|
|
- if FindData(AData,APosition) then begin
|
|
|
|
|
|
+ if FindDataPos(AData,APosition) then begin
|
|
Result := True;
|
|
Result := True;
|
|
AFoundData := LoadData(APosition);
|
|
AFoundData := LoadData(APosition);
|
|
end else begin
|
|
end else begin
|
|
@@ -572,6 +573,13 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TAbstractMemBTreeDataAbstract<TBTreeData>.FindData(
|
|
function TAbstractMemBTreeDataAbstract<TBTreeData>.FindData(
|
|
|
|
+ const AData: TBTreeData; var AFoundData: TBTreeData): Boolean;
|
|
|
|
+var LPos : TAbstractMemPosition;
|
|
|
|
+begin
|
|
|
|
+ Result := FindData(AData,LPos,AFoundData);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TAbstractMemBTreeDataAbstract<TBTreeData>.FindDataPos(
|
|
const AData: TBTreeData; out APosition: TAbstractMemPosition): Boolean;
|
|
const AData: TBTreeData; out APosition: TAbstractMemPosition): Boolean;
|
|
begin
|
|
begin
|
|
FAbstractBTreeLock.Acquire;
|
|
FAbstractBTreeLock.Acquire;
|
|
@@ -657,7 +665,7 @@ begin
|
|
while (Result) and (i<FIndexes.Count) do begin
|
|
while (Result) and (i<FIndexes.Count) do begin
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
if (Not LBTreeIndex.AllowDuplicates) then begin
|
|
if (Not LBTreeIndex.AllowDuplicates) then begin
|
|
- Result := Not (LBTreeIndex.FindData(AData,LIndexPosition));
|
|
|
|
|
|
+ Result := Not (LBTreeIndex.FindDataPos(AData,LIndexPosition));
|
|
end;
|
|
end;
|
|
inc(i);
|
|
inc(i);
|
|
end;
|
|
end;
|
|
@@ -696,12 +704,12 @@ begin
|
|
while (Result) and (i<FIndexes.Count) do begin
|
|
while (Result) and (i<FIndexes.Count) do begin
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
if (Not LBTreeIndex.AllowDuplicates) then begin
|
|
if (Not LBTreeIndex.AllowDuplicates) then begin
|
|
- Result := Not (LBTreeIndex.FindData(AData,LIndexPosition));
|
|
|
|
|
|
+ Result := Not (LBTreeIndex.FindDataPos(AData,LIndexPosition));
|
|
end;
|
|
end;
|
|
inc(i);
|
|
inc(i);
|
|
end;
|
|
end;
|
|
if (Result) And (Not AllowDuplicates) then begin
|
|
if (Result) And (Not AllowDuplicates) then begin
|
|
- Result := Not FindData(AData,LIndexPosition);
|
|
|
|
|
|
+ Result := Not FindDataPos(AData,LIndexPosition);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -734,11 +742,11 @@ var LAbstractMemPos, LindexPosition : TAbstractMemPosition;
|
|
i : Integer;
|
|
i : Integer;
|
|
LBTreeIndex : TAbstractMemBTreeDataIndex<TBTreeData>;
|
|
LBTreeIndex : TAbstractMemBTreeDataIndex<TBTreeData>;
|
|
begin
|
|
begin
|
|
- if FindData(AData,LAbstractMemPos) then begin
|
|
|
|
|
|
+ if FindDataPos(AData,LAbstractMemPos) then begin
|
|
// Delete from indexes
|
|
// Delete from indexes
|
|
for i := 0 to FIndexes.Count-1 do begin
|
|
for i := 0 to FIndexes.Count-1 do begin
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
LBTreeIndex := TAbstractMemBTreeDataIndex<TBTreeData>(FIndexes.Items[i]);
|
|
- if Not LBTreeIndex.FindData(AData,LindexPosition) then raise EAbstractMemBTree.Create(Format('Fatal error Data not found in index %d/%d to Delete from pos %s',[i+1,Findexes.Count,LAbstractMemPos.ToHexString]));
|
|
|
|
|
|
+ if Not LBTreeIndex.FindDataPos(AData,LindexPosition) then raise EAbstractMemBTree.Create(Format('Fatal error Data not found in index %d/%d to Delete from pos %s',[i+1,Findexes.Count,LAbstractMemPos.ToHexString]));
|
|
if not LBTreeIndex.DeleteInherited(LindexPosition) then raise EAbstractMemBTree.Create(Format('Fatal error Data not deleted in index %d/%d from pos %s at pos %s',[i+1,Findexes.Count,LAbstractMemPos.ToHexString,LindexPosition.ToHexString]));
|
|
if not LBTreeIndex.DeleteInherited(LindexPosition) then raise EAbstractMemBTree.Create(Format('Fatal error Data not deleted in index %d/%d from pos %s at pos %s',[i+1,Findexes.Count,LAbstractMemPos.ToHexString,LindexPosition.ToHexString]));
|
|
FAbstractMem.Dispose(LindexPosition);
|
|
FAbstractMem.Dispose(LindexPosition);
|
|
end;
|
|
end;
|