Skip to content

Commit

Permalink
Merge branch 'PascalCoinDev:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarreno committed Nov 27, 2023
2 parents 105a10e + bc6f2b0 commit aba8ab5
Show file tree
Hide file tree
Showing 7 changed files with 990 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/libraries/abstractmem/ConfigAbstractMem.inc
Expand Up @@ -75,9 +75,12 @@
Version 1.7 - April 2023
- Added TMemoryBTreeData<TData> structures that allows multiple indexes via "AddIndex" method creating TMemoryBTreeDataIndex<TBTreeData> objects

Version 1.8 - October 2023
- Added TAbstractStorage that helps in an easy to implement AbstractMemory structs in a formal way

}

const
CT_ABSTRACTMEM_VERSION = 1.7; // Each revision should increase this version...
CT_ABSTRACTMEM_VERSION = 1.8; // Each revision should increase this version...


28 changes: 28 additions & 0 deletions src/libraries/abstractmem/UAbstractMemBTree.pas
Expand Up @@ -95,6 +95,7 @@ interface
property InitialZone : TAMZone read FInitialZone;
function GetNullData : TAbstractMemPosition; override;
property BTreeCache : TAVLABTreeCache read FBTreeCache;
class function GetInfo(AAbstractMem : TAbstractMem; AInitialZone: TAMZone; out AAllowDuplicates : Boolean; out AOrder, ACount : Integer): Boolean;
End;

{$IFnDEF FPC}
Expand Down Expand Up @@ -295,6 +296,33 @@ procedure TAbstractMemBTree.DisposeNode(var ANode: TAbstractBTree<TAbstractMemPo
end;
end;

class function TAbstractMemBTree.GetInfo(AAbstractMem: TAbstractMem;
AInitialZone: TAMZone; out AAllowDuplicates: Boolean;
out AOrder, ACount: Integer): Boolean;
var LBuff : TBytes;
i : Integer;
amz : TAMZone;
ii : UInt64;
begin
AAllowDuplicates := false;
AOrder := 0;
Result := False;
//
if Not AAbstractMem.GetUsedZoneInfo(AInitialZone.position,False,amz) then Exit(False);
if amz.position=0 then Exit(False);
if (amz.size<MinAbstractMemInitialPositionSize(AAbstractMem)) then Exit(False);
SetLength(LBuff,MinAbstractMemInitialPositionSize(AAbstractMem));
AAbstractMem.Read(amz.position,LBuff[0],Length(LBuff));
// Check magic
for i := 0 to CT_AbstractMemBTree_Magic.Length-1 do begin
if LBuff[i]<>Ord(CT_AbstractMemBTree_Magic.Chars[i]) then Exit;
end;
Move(LBuff[4],ii,AAbstractMem.SizeOfAbstractMemPosition);
Move(LBuff[4+AAbstractMem.SizeOfAbstractMemPosition],ACount,4);
Move(LBuff[8+AAbstractMem.SizeOfAbstractMemPosition],AOrder,4);
Result := (AOrder>=3) and (ACount>=0);
end;

function TAbstractMemBTree.GetNode(AIdentify: TAbstractMemPosition): TAbstractBTree<TAbstractMemPosition, TAbstractMemPosition>.TAbstractBTreeNode;
var LBuff : TBytes;
i, LChildsCount : Integer;
Expand Down

0 comments on commit aba8ab5

Please sign in to comment.