2004-07-29 06:33:18 +00:00
|
|
|
program X2UtHashesTest;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
uses
|
|
|
|
madExcept,
|
|
|
|
madLinkDisAsm,
|
|
|
|
SysUtils,
|
|
|
|
X2UtHashes,
|
2004-08-20 10:03:59 +00:00
|
|
|
X2UtBinaryTree,
|
|
|
|
FBTree in 'Forms\FBTree.pas' {frmBTree};
|
2004-07-29 06:33:18 +00:00
|
|
|
|
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
<<<<<<< .working
|
2004-07-29 06:33:18 +00:00
|
|
|
procedure DebugBTree(const ANode: PX2UtBTreeNode; const AIndent: Integer = 0);
|
|
|
|
begin
|
|
|
|
WriteLn(StringOfChar(' ', AIndent), ANode^.Index);
|
|
|
|
|
|
|
|
if Assigned(ANode^.Left) then
|
|
|
|
DebugBTree(ANode^.Left, AIndent + 2);
|
|
|
|
|
|
|
|
if Assigned(ANode^.Right) then
|
|
|
|
DebugBTree(ANode^.Right, AIndent + 2);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
THackBTree = class(TX2UtCustomBTree);
|
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
=======
|
|
|
|
>>>>>>> .merge-right.r40
|
2004-07-29 06:33:18 +00:00
|
|
|
var
|
|
|
|
shData: TX2UtStringHash;
|
|
|
|
btTest: TX2UtStringBTree;
|
|
|
|
iItem: Integer;
|
|
|
|
pItem: PX2UtBTreeNode;
|
|
|
|
|
|
|
|
begin
|
|
|
|
// Test binary tree
|
|
|
|
{
|
|
|
|
btTest := TX2UtStringBTree.Create();
|
|
|
|
try
|
|
|
|
Randomize();
|
2004-08-20 10:03:59 +00:00
|
|
|
for iItem := 0 to 61 do
|
2004-07-29 06:33:18 +00:00
|
|
|
btTest[Random(500)] := 'bla';
|
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
<<<<<<< .working
|
2004-07-29 06:33:18 +00:00
|
|
|
btTest[300] := 'bla';
|
|
|
|
btTest.Delete(300);
|
2004-08-20 10:03:59 +00:00
|
|
|
=======
|
|
|
|
TfrmBTree.Execute(btTest);
|
|
|
|
>>>>>>> .merge-right.r40
|
2004-07-29 06:33:18 +00:00
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
<<<<<<< .working
|
2004-07-29 06:33:18 +00:00
|
|
|
// Heh, hacking my own class. This is just for debugging the tree,
|
|
|
|
// there should never be any need to access the root node outside of the
|
|
|
|
// class otherwise, so I made it protected.
|
|
|
|
pItem := THackBTree(btTest).Root;
|
|
|
|
DebugBTree(pItem);
|
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
=======
|
|
|
|
>>>>>>> .merge-right.r40
|
2004-07-29 06:33:18 +00:00
|
|
|
WriteLn;
|
|
|
|
btTest.Reset();
|
|
|
|
while btTest.Next() do
|
|
|
|
WriteLn(btTest.CurrentIndex, ' - ', btTest.CurrentValue);
|
|
|
|
finally
|
|
|
|
FreeAndNil(btTest);
|
2004-08-20 10:03:59 +00:00
|
|
|
//ReadLn;
|
2004-07-29 06:33:18 +00:00
|
|
|
end;
|
|
|
|
}
|
|
|
|
|
|
|
|
shData := TX2UtStringHash.Create();
|
|
|
|
try
|
2004-07-29 15:49:42 +00:00
|
|
|
shData['thisakslhalskdjfhaslkdfjhaslkfjh'] := 'is';
|
2004-07-29 06:33:18 +00:00
|
|
|
shData['a'] := 'test';
|
|
|
|
|
2004-08-20 10:03:59 +00:00
|
|
|
TfrmBTree.Execute(shData);
|
|
|
|
|
|
|
|
{
|
2004-07-29 06:33:18 +00:00
|
|
|
shData.Reset();
|
|
|
|
while shData.Next() do
|
2004-07-29 13:48:35 +00:00
|
|
|
WriteLn(shData.CurrentKey, ': ', shData.CurrentValue, ' (',
|
|
|
|
shData[shData.CurrentKey], ')');
|
2004-08-20 10:03:59 +00:00
|
|
|
}
|
2004-07-29 06:33:18 +00:00
|
|
|
finally
|
|
|
|
FreeAndNil(shData);
|
2004-08-20 10:03:59 +00:00
|
|
|
//ReadLn;
|
2004-07-29 06:33:18 +00:00
|
|
|
end;
|
|
|
|
end.
|