; _______________________________________________________________________________________
;|                                                                                       |
;| ..:: Fresh IDE ::..  template project.                                                |
;|_______________________________________________________________________________________|
;
;  Description: FreshLib portable console application.
;
;  Target OS: Any, supported by FreshLib
;
;  Dependencies: FreshLib
;
;  Notes:
;_________________________________________________________________________________________

include "%lib%/freshlib.inc"

@BinaryType console, compact

options.DebugMode = 1

include "%lib%/freshlib.asm"


include "%lib%/data/hashtree.asm"

start:
        InitializeAll

        mov     [ResizeIt], StrategyAgressive

        stdcall CreateArray, sizeof.THashTreeNode
        mov     edx, eax
        mov     ecx, 10000000

.add_loop:
        stdcall StrDupMem, "Test string"
        mov     ebx, eax

        stdcall NumToStr, ecx, ntsDec or ntsUnsigned
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax

        stdcall SearchHashTree, edx, ebx, TRUE
        test    eax, eax
        jnz     @f

        stdcall StrDel, ebx
        OutputValue "String add error on ECX=", ecx, 10, -1
@@:
        loop    .add_loop

        OutputValue "Hash tree size: ", [edx+TArray.count], 10, -1

        stdcall FreeHashTree, edx

        FinalizeAll
        stdcall TerminateAll, 0
