2002-07-14 14:14 UTC+0500 April White <awhite@mail.rosecom.ca>

* contrib/btree/hb_btree.api
    + extern "C"
    * rename nFlags to ulFlags
    + declaration for hb_BTreeDataItem()
    * declaration for hb_BTreeInsert() to use a PHB_ITEM vs LONG

  * contrib/btree/hb_btree.ch
    - comments from around 'inmemory' definition

  * contrib/btree/test/test.prg
    + code to test in-memory tree, including passing floats vs longs

  * contrib/btree/test/ctest.c
    ! a SEEK call that was incorrectly failing because the
      DATA param passed as 0
    * hb_BTreeInsert() calls to use new form (PHB_ITEM vs long)

  * contrib/btree/hb_btree.c
    ; the following warnings are reported by BCC (thanks Alexander):
        Suspicious pointer conversion in function hb_BTreeNew & hb_BTreeOpen
          pBTree->pStrCompare = strncmp;
        Parameter 'ulFlags' is never used in function hb_BTreeOpen
    - defintion and use of DBG() macro
    + extern "C" ifdef'd
    - comments from around 'inmemory' definition
    * renamed nFlags to ulFlags, lFlags to ulFlags, position to iPosition
    * hb_btreenew [hi level] - when flag contains HB_BTREE_INMEMORY,
first
      parameter is ignored
    * hb_btreenew [lo level] - when flag contains HB_BTREE_INMEMORY,
dont
      try to open the file, etc, and clear necessary fields
    * hb_btreeclose [lo level] - close file and release file name only when
      necessary
    * only call HeaderWrite() when not in-memory tree
    + ioOneBufferAlloc() - allocate one ioBuffer_T block, called by
      ioBufferAlloc(), and Grow() when in-memory
    * Grow() in-memory - add a page to the link list
    + Prune() in-memory - added code to remove a page from the link list
    * (assorted) IsDirty flag is assigned the tree property IsDirtyFlagAssignment,
      so that in-memory trees never fire the write methods (ie. always false)
    * hb_BTreeGoTop(), hb_BTreeGoBottom() [lo-level]
      + bug fix: preserve last node found
      + if tree is empty, clear key/data, else retrieve selected key/data
    * ioBufferRead() - moved IsDirty reset within "if ( IsDirty )" block
    * ioBufferScan() - call ioBufferRead() when not in-memory tree
    - SearchNode() redundant BufferRelease() and return statement
    - enum ExceptionTypes (not used)
    - Buffer_T typedef struct, incorporating into the ioBuffer_T typedef struct
    * hb_KeyData_T: replaced lData with a union lData/pData
    + definition for hb_BTreeDataItem()
    * definition for hb_BTreeInsert() to use a PHB_ITEM vs LONG
    * hb_btreeinsert() [hi-level] accepts only number for file i/o and
      any data type for in-memory
    - macro SETKEYDATA(), placing equivalent code into hb_BTreeInsert()
    + Prune() - release individial items and then the page itself
    ! CountAdj() last param should have been SHORT not USHORT
    ; RecDelete() moved the inline assignment & comparision around to remove
      the b32 warning

    TODO: find a solution to the 'Suspicious pointer conversion in function
          hb_BTreeNew & hb_BTreeOpen' [strncmp() & hb_strncmp()]

    TODO: impliment ulFlags within hb_btreeopen() - see warning above
          - clear im-memory flag
          - get unique flag from file header

  * contrib/btree/doc/hb_btree.txt
    * spelling corrections
    * clarified use of HB_BTREE_INMEMORY flag with hb_BTreeNew() API
    ! corrected type of pBTree params, from 'hb_BTree *' to 'struct hb_BTree *'
    + definition for hb_BTreeDataItem()
    * clarified use of data param and data return value
This commit is contained in:
April White
2002-07-14 13:55:16 +00:00
parent d3979c3d29
commit 5fe776f5a2
9 changed files with 971 additions and 551 deletions

View File

@@ -8,6 +8,77 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2002-07-14 14:14 UTC+0500 April White <awhite@mail.rosecom.ca>
* contrib/btree/hb_btree.api
+ extern "C"
* rename nFlags to ulFlags
+ declaration for hb_BTreeDataItem()
* declaration for hb_BTreeInsert() to use a PHB_ITEM vs LONG
* contrib/btree/hb_btree.ch
- comments from around 'inmemory' definition
* contrib/btree/test/test.prg
+ code to test in-memory tree, including passing floats vs longs
* contrib/btree/test/ctest.c
! a SEEK call that was incorrectly failing because the
DATA param passed as 0
* hb_BTreeInsert() calls to use new form (PHB_ITEM vs long)
* contrib/btree/hb_btree.c
; the following warnings are reported by BCC (thanks Alexander):
Suspicious pointer conversion in function hb_BTreeNew & hb_BTreeOpen
pBTree->pStrCompare = strncmp;
Parameter 'ulFlags' is never used in function hb_BTreeOpen
- defintion and use of DBG() macro
+ extern "C" ifdef'd
- comments from around 'inmemory' definition
* renamed nFlags to ulFlags, lFlags to ulFlags, position to iPosition
* hb_btreenew [hi level] - when flag contains HB_BTREE_INMEMORY, first
parameter is ignored
* hb_btreenew [lo level] - when flag contains HB_BTREE_INMEMORY, dont
try to open the file, etc, and clear necessary fields
* hb_btreeclose [lo level] - close file and release file name only when
necessary
* only call HeaderWrite() when not in-memory tree
+ ioOneBufferAlloc() - allocate one ioBuffer_T block, called by
ioBufferAlloc(), and Grow() when in-memory
* Grow() in-memory - add a page to the link list
+ Prune() in-memory - added code to remove a page from the link list
* (assorted) IsDirty flag is assigned the tree property IsDirtyFlagAssignment,
so that in-memory trees never fire the write methods (ie. always false)
* hb_BTreeGoTop(), hb_BTreeGoBottom() [lo-level]
+ bug fix: preserve last node found
+ if tree is empty, clear key/data, else retrieve selected key/data
* ioBufferRead() - moved IsDirty reset within "if ( IsDirty )" block
* ioBufferScan() - call ioBufferRead() when not in-memory tree
- SearchNode() redundant BufferRelease() and return statement
- enum ExceptionTypes (not used)
- Buffer_T typedef struct, incorporating into the ioBuffer_T typedef struct
* hb_KeyData_T: replaced lData with a union lData/pData
+ definition for hb_BTreeDataItem()
* definition for hb_BTreeInsert() to use a PHB_ITEM vs LONG
* hb_btreeinsert() [hi-level] accepts only number for file i/o and
any data type for in-memory
- macro SETKEYDATA(), placing equivalent code into hb_BTreeInsert()
+ Prune() - release individial items and then the page itself
! CountAdj() last param should have been SHORT not USHORT
; RecDelete() moved the inline assignment & comparision around to remove
the b32 warning
TODO: find a solution to the 'Suspicious pointer conversion in function
hb_BTreeNew & hb_BTreeOpen' [strncmp() & hb_strncmp()]
TODO: impliment ulFlags within hb_btreeopen() - see warning above
- clear im-memory flag
- get unique flag from file header
* contrib/btree/doc/hb_btree.txt
* spelling corrections
* clarified use of HB_BTREE_INMEMORY flag with hb_BTreeNew() API
! corrected type of pBTree params, from 'hb_BTree *' to 'struct hb_BTree *'
+ definition for hb_BTreeDataItem()
* clarified use of data param and data return value
2002-07-14 12:35 UTC+0100 Antonio Linares <alinares@fivetech.com>
* source/debug/debugger.prg
* Changes from Davor Siklic

View File

@@ -120,7 +120,7 @@
* hb_BTreeOpen() - when set, the file I/O mode FO_READONLY is used,
* preventing insertions or deletions to the BTree; if the BTree file
* has the read-only file attribute set, the flag HB_BTREE_EXCLUSIVE is
* assumed and activated internal API optimizations
* assumed and activates internal API optimizations
*
* HB_BTREE_EXCLUSIVE - when set, the file I/O mode FO_EXCLUSIVE is used,
* preventing shared access, and activates internal API optimizations
@@ -133,7 +133,8 @@
* BTree control flags:
*
* HB_BTREE_UNIQUE - when set, the key and data together determine uniqueness;
* when not set, the key alone determines uniqueness.
* when not set, the key alone determines uniqueness. This flag cannot
* be used with the HB_BTREE_INMEMORY flag!
*
* HB_BTREE_CASELESS - when set, comparison of keys is done in a case-insensitive
* manner; when not set, comparisons are case sensitive
@@ -142,7 +143,8 @@
* in memory; when not set, the BTree is built and maintained as a file.
* The use of this flag precludes the use of the creation/access flags listed
* above - an in-memory BTree cannot be shared, made read-only, and is also
* exclusive by definition
* exclusive by definition. This flag cannot be used with hb_BTreeOpen().
* This flag is mutually exclusive of the HB_BTREE_UNIQUE.
* $SEEALSO$
* hb_BTreeNew(), hb_BTreeOpen()
* $END$
@@ -159,7 +161,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeNew( CHAR <cFileName>, int <nPageSize>, int <nKeySize>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ) -> ( hb_BTree * )pHBTree
* hb_BTreeNew( CHAR <cFileName>, int <nPageSize>, int <nKeySize>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ) -> ( struct hb_BTree * )pHBTree
*
* Harbour Prototype
*
@@ -169,7 +171,8 @@
*
* TBTreeNew( CHAR <cFileName>, <nPageSize>, <nKeySize>, [ <nFlags> ], [ <nBuffers>=1 ] ) -> <tBTreeInstance>
* $ARGUMENTS$
* <cFileName> Name of BTree file to create
* <cFileName> Name of BTree file to create. This parameter is optional
* if the flag HB_BTREE_INMEMORY is used
*
* <nPageSize> Number of bytes one file 'page' is to be; must be a multiple of 2048.
* If the hb_btree library is compiled with the value HB_BTREE_HEADERSIZE
@@ -197,8 +200,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -217,7 +221,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeOpen( CHAR <cFileName>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ] ) -> ( hb_BTree * )pHBTree
* hb_BTreeOpen( CHAR <cFileName>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ] ) -> ( struct hb_BTree * )pHBTree
*
* Harbour Prototype
*
@@ -249,8 +253,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -269,7 +274,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeClose( hb_BTree * <pBTree> ) -> NIL
* hb_BTreeClose( struct hb_BTree * <pBTree> ) -> NIL
*
* Harbour Prototype
*
@@ -297,8 +302,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -317,15 +323,15 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeInsert( hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
* hb_BTreeInsert( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
*
* Harbour Prototype
*
* hb_BTreeInsert( <hb_BTree_Handle>, <cKey>, <lData> ) -> <lSuccess>
* hb_BTreeInsert( <hb_BTree_Handle>, <cKey>, <lData> | <xData> ) -> <lSuccess>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Insert( <cKey>, <lData> ) -> <lSuccess>
* <tBTreeInstance>:Insert( <cKey>, <lData> | <xData> ) -> <lSuccess>
* $ARGUMENTS$
* C Prototype
*
@@ -341,7 +347,8 @@
*
* <cKey> A string, representing a key value to be inserted
*
* <lData> A numeric data value to associate with the <cKey> value
* <lData> A numeric data value to associate with the <cKey> value, or </par>
* <xData> Any value to associate with the <cKey> value
*
* Harbour Class Prototype
*
@@ -349,7 +356,8 @@
*
* <cKey> A string, representing a key value to be inserted
*
* <lData> A numeric data value to associate with the <cKey> value
* <lData> A numeric data value to associate with the <cKey> value, or </par>
* <xData> Any value to associate with the <cKey> value
* $RETURNS$
* <lSuccess> Logical value indicating whether the operation succeeded
* $DESCRIPTION$
@@ -357,8 +365,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -377,7 +386,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeDelete( hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
* hb_BTreeDelete( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
*
* Harbour Prototype
*
@@ -417,8 +426,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -437,7 +447,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BtreeKey( hb_BTree * <pBTree> ) -> CHAR <cKey>
* hb_BtreeKey( struct hb_BTree * <pBTree> ) -> CHAR <cKey>
*
* Harbour Prototype
*
@@ -475,8 +485,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -495,15 +506,15 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BtreeData( hb_BTree * <pBTree> ) -> LONG <lData>
* hb_BtreeData( struct hb_BTree * <pBTree> ) -> LONG <lData>
*
* Harbour Prototype
*
* hb_BtreeData( <hb_BTree_Handle> ) -> <lData>
* hb_BtreeData( <hb_BTree_Handle> ) -> <lData> | <xData>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Data() -> <lData>
* <tBTreeInstance>:Data() -> <lData> | <xData>
* $ARGUMENTS$
* C Prototype
*
@@ -523,22 +534,53 @@
*
* Harbour Prototype
*
* <lData> The numeric value associated with the active key
* <lData> The numeric value associated with the active key, or</par>
* <xData> The value associated with an active key of an in-memory btree
*
* Harbour Class Prototype
*
* <lData> The numeric value associated with the active key
* <lData> The numeric value associated with the active key, or</par>
* <xData> The value associated with an active key of an in-memory btree
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* hb_BtreeDataItem()
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BtreeDataItem()
* $CATEGORY$
* BTree C API
* $ONELINER$
* Returns the active data value for an active BTree file
* $SYNTAX$
* #include "hb_btree.api"
* hb_BtreeDataItem( struct hb_BTree * <pBTree> ) -> PHB_ITEM <xData>
* $ARGUMENTS$
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
* $RETURNS$
* <xData> A pointer to a constant PHB_ITEM value, or NIL if none was assigned
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* hb_BtreeData()
* $END$
*/
@@ -553,7 +595,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeGoTop( hb_BTree * <pBTree> ) -> void
* hb_BTreeGoTop( struct hb_BTree * <pBTree> ) -> void
*
* Harbour Prototype
*
@@ -581,8 +623,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -601,7 +644,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeGoBottom( hb_BTree * <pBTree> ) -> void
* hb_BTreeGoBottom( struct hb_BTree * <pBTree> ) -> void
*
* Harbour Prototype
*
@@ -629,8 +672,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -649,7 +693,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeSkip( hb_BTree * <pBTree>, LONG <nRecords> ) -> LONG <nRecordsSkipped>
* hb_BTreeSkip( struct hb_BTree * <pBTree>, LONG <nRecords> ) -> LONG <nRecordsSkipped>
*
* Harbour Prototype
*
@@ -683,8 +727,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -703,7 +748,7 @@
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeSeek( hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData>, BOOL <lSoftSeek> ) -> BOOL <lSuccess>
* hb_BTreeSeek( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData>, BOOL <lSoftSeek> ) -> BOOL <lSuccess>
*
* Harbour Prototype
*
@@ -719,7 +764,9 @@
*
* <cKey> A pointer to a CHAR buffer containing the key to locate
*
* <lData> The long value associated with the key
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
*
@@ -729,7 +776,9 @@
*
* <cKey> A string containing the key to locate
*
* <lData> The long value associated with the key
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
*
@@ -739,7 +788,9 @@
*
* <cKey> A string containing the key to locate
*
* <lData> The long value associated with the key
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
* $RETURNS$
@@ -751,8 +802,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
@@ -780,15 +832,15 @@
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <nIndex> Optional. One of:
* HB_BTREEINFO_ALL (0) - default value
* HB_BTREEINFO_FILENAME (1)
* HB_BTREEINFO_PAGESIZE (2)
* HB_BTREEINFO_KEYSIZE (3)
* HB_BTREEINFO_MAXKEYS (4)
* HB_BTREEINFO_MINKEYS (5)
* HB_BTREEINFO_FLAGS (6)
* HB_BTREEINFO_KEYCOUNT (7)
* <nIndex> Optional. One of:</par>
* HB_BTREEINFO_ALL (0) - default value</par>
* HB_BTREEINFO_FILENAME (1)</par>
* HB_BTREEINFO_PAGESIZE (2)</par>
* HB_BTREEINFO_KEYSIZE (3)</par>
* HB_BTREEINFO_MAXKEYS (4)</par>
* HB_BTREEINFO_MINKEYS (5)</par>
* HB_BTREEINFO_FLAGS (6)</par>
* HB_BTREEINFO_KEYCOUNT (7)</par>
*
* Harbour Class Prototype
*
@@ -806,8 +858,9 @@
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree
* Header is hb_btree.api
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$

View File

@@ -33,17 +33,38 @@
*
*/
/* Changelog
* Changed, bla-bla
! Fixed
% Optimized
+ Added
- Removed
; Comment
* contrib/btree/hb_btree.api
+ extern "C"
* rename nFlags to ulFlags
+ declaration for hb_BTreeDataItem()
* declaration for hb_BTreeInsert() to use a PHB_ITEM vs LONG
*/
#ifndef HB_BTREE_API
#define HB_BTREE_API
#if defined(HB_EXTERN_C)
extern "C" {
#endif
#include "hb_btree.ch"
struct hb_BTree;
struct hb_BTree * hb_BTreeNew( BYTE *FileName, USHORT usPageSize, USHORT usKeySize, ULONG nFlags, USHORT usBuffers );
struct hb_BTree * hb_BTreeNew( BYTE *FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers );
struct hb_BTree * hb_BTreeOpen( BYTE *FileName, ULONG lFlags, USHORT usBuffers );
void hb_BTreeClose( struct hb_BTree * pBTree );
BOOL hb_BTreeInsert( struct hb_BTree * pBTree, BYTE * szKey, LONG lData );
BOOL hb_BTreeInsert( struct hb_BTree * pBTree, BYTE * szKey, PHB_ITEM pData );
BOOL hb_BTreeDelete( struct hb_BTree * pBTree, BYTE * szKey, LONG lData );
void hb_BTreeGoTop( struct hb_BTree * pBTree );
void hb_BTreeGoBottom( struct hb_BTree * pBTree );
@@ -51,5 +72,10 @@ BOOL hb_BTreeSeek( struct hb_BTree * pBTree, BYTE * szKey, LONG lData, BOOL bSof
LONG hb_BTreeSkip( struct hb_BTree * pBTree, LONG nRecords );
const BYTE * hb_BTreeKey( struct hb_BTree * pBTree );
LONG hb_BTreeData( struct hb_BTree * pBTree );
const PHB_ITEM hb_BTreeDataItem( struct hb_BTree * pBTree );
#if defined(HB_EXTERN_C)
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,20 @@
*
*/
/* Changelog
* Changed, bla-bla
! Fixed
% Optimized
+ Added
- Removed
; Comment
* contrib/btree/hb_btree.ch
- comments from around 'inmemory' definition
*/
#ifndef HB_BTREE_CH
#define HB_BTREE_CH
@@ -45,10 +59,7 @@
#define HB_BTREE_UNIQUE 128
#define HB_BTREE_CASELESS 256
/*
#define HB_BTREE_INMEMORY 512 * do not use! *
*/
#define HB_BTREE_INMEMORY 512
#define HB_BTREEINFO_ALL 0
#define HB_BTREEINFO_FILENAME 1

View File

@@ -4,12 +4,18 @@ cd test\dos\djgpp\
del test.exe
del *.c
gcc -I. -I../../../../../include -I../../.. -Wall -c ../../ctest.c -octest.o
..\..\..\..\..\source\compiler\dos\djgpp\harbour.exe ../../test.prg -n -q0 -w -es2 -gc0 -I../../ -I../../../ -I../../../../../include
..\..\..\..\..\source\compiler\dos\djgpp\harbour.exe ../../ttest.prg -n -q0 -w -es2 -gc0 -I../../ -I../../../ -I../../../../../include
gcc -I. -I../../../../../include -Wall -c test.c -otest.o
..\..\..\..\..\source\compiler\dos\djgpp\harbour.exe ../../ttest.prg -n -q0 -w -es2 -gc0 -I../../ -I../../../ -I../../../../../include
gcc -I. -I../../../../../include -Wall -c ttest.c -ottest.o
gcc -I. -I../../../../../include -I../../.. -Wall -c ../../ctest.c -octest.o
gcc @__link__.tmp
cd ..\..\..
pause
test\dos\djgpp\test
:done

View File

@@ -10,54 +10,47 @@
#include "hb_btree.api"
static void insertdata( struct hb_BTree * pBTree );
static void display( const BYTE *cKey, LONG lData );
static void display( const BYTE *cKey, LONG lData, BOOL NewLine );
HB_FUNC( CTEST )
{
struct hb_BTree * pBTree;
display( "Harbour API test", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Harbour API test", 0, TRUE );
pBTree = hb_BTreeNew( "test_3.out", 2048, 90, HB_BTREE_UNIQUE, 0 );
if ( pBTree != NULL )
{
/*
a := hb_BTreeInfo( pBTree );
display( "File", a[ hb_BTreeINFO_FILENAME ] );
display( "Page", a[ hb_BTreeINFO_PAGESIZE ] );
display( "Key ", a[ hb_BTreeINFO_KEYSIZE ] );
display( "Max ", a[ hb_BTreeINFO_MAXKEYS ] );
display( "Min ", a[ hb_BTreeINFO_MINKEYS ] );
display( "Flag", a[ hb_BTreeINFO_FLAGS ] );
display( "Keys", a[ hb_BTreeINFO_KEYCOUNT ] );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "File", a[ hb_BTreeINFO_FILENAME ], FALSE );
display( "Page", a[ hb_BTreeINFO_PAGESIZE ], FALSE );
display( "Key ", a[ hb_BTreeINFO_KEYSIZE ], FALSE );
display( "Max ", a[ hb_BTreeINFO_MAXKEYS ], FALSE );
display( "Min ", a[ hb_BTreeINFO_MINKEYS ], FALSE );
display( "Flag", a[ hb_BTreeINFO_FLAGS ], FALSE );
display( "Keys", a[ hb_BTreeINFO_KEYCOUNT ], TRUE );
*/
insertdata( pBTree );
/*
display( "Keys", hb_BTreeInfo( pBTree, hb_BTreeINFO_KEYCOUNT ) );
display( "Keys", hb_BTreeInfo( pBTree, hb_BTreeINFO_KEYCOUNT ), TRUE );
*/
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Forward traversal", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Forward traversal", 0, TRUE );
hb_BTreeGoTop( pBTree );
while ( TRUE )
{
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
if ( 2 != hb_BTreeSkip( pBTree, 2 ) )
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
if ( 1 != hb_BTreeSkip( pBTree, 1 ) )
{
break;
}
}
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Reverse traversal", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Reverse traversal", 0, TRUE );
hb_BTreeGoBottom( pBTree );
while ( TRUE )
{
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
if ( -1 != hb_BTreeSkip( pBTree, -1 ) )
{
break;
@@ -65,55 +58,46 @@ HB_FUNC( CTEST )
}
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test SEEK", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "", hb_BTreeSeek( pBTree, "cdntyzrf", 0, FALSE ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test SEEK", 0, TRUE );
display( hb_BTreeSeek( pBTree, "cdntyzrf", 36, FALSE ) == 1 ? ".T." : ".F.", 0, TRUE );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
hb_BTreeSkip( pBTree, 1 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) ); display( " dmfmivqb ?", 0 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), FALSE );
display( " dmfmivqb ?", 0, TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a short key", 0, TRUE );
display( hb_BTreeSeek( pBTree, "cd", 0, TRUE ) == 1 ? ".T." : ".F.", 0, TRUE );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
hb_BTreeSkip( pBTree, 1 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), FALSE );
display( " dmfmivqb ?", 0, TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a short key", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "", hb_BTreeSeek( pBTree, "cd", 0, TRUE ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of an existing key", 0, TRUE );
display( hb_BTreeSeek( pBTree, "cdntyzrf", 0, TRUE ) == 1 ? ".T." : ".F.", 0, TRUE );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
hb_BTreeSkip( pBTree, 1 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) ); display( " dmfmivqb ?", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), FALSE );
display( " dmfmivqb ?", 0, TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of an existing key", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "", hb_BTreeSeek( pBTree, "cdntyzrf", 0, TRUE ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a missing key, that should force EOF", 0, TRUE );
display( hb_BTreeSeek( pBTree, "zzzzzz", 0, FALSE ) == 1 ? ".T." : ".F.", 0, TRUE );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), TRUE );
hb_BTreeSkip( pBTree, 1 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) ); display( " dmfmivqb ?", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a missing key, that should force EOF", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "", hb_BTreeSeek( pBTree, "zzzzzz", 0, FALSE ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
hb_BTreeSkip( pBTree, 1 );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ) ); display( " dmfmivqb ?", 0 );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), FALSE );
display( " dmfmivqb ?", 0, TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
hb_BTreeClose( pBTree );
}
else
{
display( "error / failure", 0 );
display( "error / failure", 0, TRUE );
}
}
static void display( const BYTE *cKey, LONG lData )
static void display( const BYTE *cKey, LONG lData, BOOL NewLine )
{
int n;
BYTE buffer[ 80 ];
@@ -127,91 +111,97 @@ static void display( const BYTE *cKey, LONG lData )
n = sprintf( buffer, "%ld", lData );
}
hb_conOutStd( buffer, n );
if ( NewLine )
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
}
static void insertdata( struct hb_BTree * pBTree )
{
hb_BTreeInsert( pBTree, "fuweqgsz", 1 );
hb_BTreeInsert( pBTree, "sjruexrd", 2 );
hb_BTreeInsert( pBTree, "fvveitnz", 3 );
hb_BTreeInsert( pBTree, "aqgksjxe", 4 );
hb_BTreeInsert( pBTree, "oonrehvj", 5 );
hb_BTreeInsert( pBTree, "gvowjwtr", 6 );
hb_BTreeInsert( pBTree, "xxidwtvn", 7 );
hb_BTreeInsert( pBTree, "rwjbxesd", 8 );
hb_BTreeInsert( pBTree, "yaznsaek", 9 );
hb_BTreeInsert( pBTree, "wbdhfkfy", 10 );
hb_BTreeInsert( pBTree, "lryaezia", 11 );
hb_BTreeInsert( pBTree, "tspmnrvk", 12 );
hb_BTreeInsert( pBTree, "hpxryhdj", 13 );
hb_BTreeInsert( pBTree, "sztcqaby", 14 );
hb_BTreeInsert( pBTree, "fcyzsqja", 15 );
hb_BTreeInsert( pBTree, "uccxumvg", 16 );
hb_BTreeInsert( pBTree, "amwuoout", 17 );
hb_BTreeInsert( pBTree, "yaytseln", 18 );
hb_BTreeInsert( pBTree, "sfiiozej", 19 );
hb_BTreeInsert( pBTree, "xuvsoljy", 20 );
hb_BTreeInsert( pBTree, "qmqjbedm", 21 );
hb_BTreeInsert( pBTree, "cctzzrkz", 22 );
hb_BTreeInsert( pBTree, "ikytgdon", 23 );
hb_BTreeInsert( pBTree, "pksobcwu", 24 );
hb_BTreeInsert( pBTree, "vmurindj", 25 );
hb_BTreeInsert( pBTree, "elvybqwg", 26 );
hb_BTreeInsert( pBTree, "ixchaztx", 27 );
hb_BTreeInsert( pBTree, "nzpztlhd", 28 );
hb_BTreeInsert( pBTree, "aucrchiw", 29 );
hb_BTreeInsert( pBTree, "munrytse", 30 );
hb_BTreeInsert( pBTree, "kqkhcmls", 31 );
hb_BTreeInsert( pBTree, "abqhurbi", 32 );
hb_BTreeInsert( pBTree, "ymrldckr", 33 );
hb_BTreeInsert( pBTree, "rhsmfflc", 34 );
hb_BTreeInsert( pBTree, "apyfkvee", 35 );
hb_BTreeInsert( pBTree, "cdntyzrf", 36 );
hb_BTreeInsert( pBTree, "iacblqrh", 37 );
hb_BTreeInsert( pBTree, "xvewqana", 38 );
hb_BTreeInsert( pBTree, "xmybqytj", 39 );
hb_BTreeInsert( pBTree, "dnowympf", 40 );
hb_BTreeInsert( pBTree, "smloihft", 41 );
hb_BTreeInsert( pBTree, "zumppmis", 42 );
hb_BTreeInsert( pBTree, "jirucnxu", 43 );
hb_BTreeInsert( pBTree, "ecdzikcv", 44 );
hb_BTreeInsert( pBTree, "slbwvnpg", 45 );
hb_BTreeInsert( pBTree, "yaftlkmz", 46 );
hb_BTreeInsert( pBTree, "blcepksd", 47 );
hb_BTreeInsert( pBTree, "xufowlpl", 48 );
hb_BTreeInsert( pBTree, "xegtjtqc", 49 );
hb_BTreeInsert( pBTree, "yplcqumq", 50 );
hb_BTreeInsert( pBTree, "vdoycauz", 51 );
hb_BTreeInsert( pBTree, "uhqkjuph", 52 );
hb_BTreeInsert( pBTree, "prllaeyi", 53 );
hb_BTreeInsert( pBTree, "ybzgmwzm", 54 );
hb_BTreeInsert( pBTree, "kkvyllnp", 55 );
hb_BTreeInsert( pBTree, "nberwsrb", 56 );
hb_BTreeInsert( pBTree, "wgetahua", 57 );
hb_BTreeInsert( pBTree, "yxcyehcv", 58 );
hb_BTreeInsert( pBTree, "oacormks", 59 );
hb_BTreeInsert( pBTree, "mcadkdxo", 60 );
hb_BTreeInsert( pBTree, "ycsalwqw", 61 );
hb_BTreeInsert( pBTree, "qmpysvjl", 62 );
hb_BTreeInsert( pBTree, "iqikamew", 63 );
hb_BTreeInsert( pBTree, "iaparrva", 64 );
hb_BTreeInsert( pBTree, "casbvtay", 65 );
hb_BTreeInsert( pBTree, "blaksexr", 66 );
hb_BTreeInsert( pBTree, "tbosrbql", 67 );
hb_BTreeInsert( pBTree, "ifkywsyt", 68 );
hb_BTreeInsert( pBTree, "gvklwevy", 69 );
hb_BTreeInsert( pBTree, "krpmpbud", 70 );
hb_BTreeInsert( pBTree, "rdvlwbwm", 71 );
hb_BTreeInsert( pBTree, "apnvdkww", 72 );
hb_BTreeInsert( pBTree, "euqdocvm", 73 );
hb_BTreeInsert( pBTree, "ksmkjcwp", 74 );
hb_BTreeInsert( pBTree, "bztgclzc", 75 );
hb_BTreeInsert( pBTree, "awkdnuxa", 76 );
hb_BTreeInsert( pBTree, "abavnpod", 77 );
hb_BTreeInsert( pBTree, "dvwvhjmh", 78 );
hb_BTreeInsert( pBTree, "dmfmivqb", 79 );
hb_BTreeInsert( pBTree, "ewsxanon", 80 );
PHB_ITEM data = hb_itemNew( NULL );
hb_BTreeInsert( pBTree, "fuweqgsz", hb_itemPutNL( data, 1 ) );
hb_BTreeInsert( pBTree, "sjruexrd", hb_itemPutNL( data, 2 ) );
hb_BTreeInsert( pBTree, "fvveitnz", hb_itemPutNL( data, 3 ) );
hb_BTreeInsert( pBTree, "aqgksjxe", hb_itemPutNL( data, 4 ) );
hb_BTreeInsert( pBTree, "oonrehvj", hb_itemPutNL( data, 5 ) );
hb_BTreeInsert( pBTree, "gvowjwtr", hb_itemPutNL( data, 6 ) );
hb_BTreeInsert( pBTree, "xxidwtvn", hb_itemPutNL( data, 7 ) );
hb_BTreeInsert( pBTree, "rwjbxesd", hb_itemPutNL( data, 8 ) );
hb_BTreeInsert( pBTree, "yaznsaek", hb_itemPutNL( data, 9 ) );
hb_BTreeInsert( pBTree, "wbdhfkfy", hb_itemPutNL( data, 10 ) );
hb_BTreeInsert( pBTree, "lryaezia", hb_itemPutNL( data, 11 ) );
hb_BTreeInsert( pBTree, "tspmnrvk", hb_itemPutNL( data, 12 ) );
hb_BTreeInsert( pBTree, "hpxryhdj", hb_itemPutNL( data, 13 ) );
hb_BTreeInsert( pBTree, "sztcqaby", hb_itemPutNL( data, 14 ) );
hb_BTreeInsert( pBTree, "fcyzsqja", hb_itemPutNL( data, 15 ) );
hb_BTreeInsert( pBTree, "uccxumvg", hb_itemPutNL( data, 16 ) );
hb_BTreeInsert( pBTree, "amwuoout", hb_itemPutNL( data, 17 ) );
hb_BTreeInsert( pBTree, "yaytseln", hb_itemPutNL( data, 18 ) );
hb_BTreeInsert( pBTree, "sfiiozej", hb_itemPutNL( data, 19 ) );
hb_BTreeInsert( pBTree, "xuvsoljy", hb_itemPutNL( data, 20 ) );
hb_BTreeInsert( pBTree, "qmqjbedm", hb_itemPutNL( data, 21 ) );
hb_BTreeInsert( pBTree, "cctzzrkz", hb_itemPutNL( data, 22 ) );
hb_BTreeInsert( pBTree, "ikytgdon", hb_itemPutNL( data, 23 ) );
hb_BTreeInsert( pBTree, "pksobcwu", hb_itemPutNL( data, 24 ) );
hb_BTreeInsert( pBTree, "vmurindj", hb_itemPutNL( data, 25 ) );
hb_BTreeInsert( pBTree, "elvybqwg", hb_itemPutNL( data, 26 ) );
hb_BTreeInsert( pBTree, "ixchaztx", hb_itemPutNL( data, 27 ) );
hb_BTreeInsert( pBTree, "nzpztlhd", hb_itemPutNL( data, 28 ) );
hb_BTreeInsert( pBTree, "aucrchiw", hb_itemPutNL( data, 29 ) );
hb_BTreeInsert( pBTree, "munrytse", hb_itemPutNL( data, 30 ) );
hb_BTreeInsert( pBTree, "kqkhcmls", hb_itemPutNL( data, 31 ) );
hb_BTreeInsert( pBTree, "abqhurbi", hb_itemPutNL( data, 32 ) );
hb_BTreeInsert( pBTree, "ymrldckr", hb_itemPutNL( data, 33 ) );
hb_BTreeInsert( pBTree, "rhsmfflc", hb_itemPutNL( data, 34 ) );
hb_BTreeInsert( pBTree, "apyfkvee", hb_itemPutNL( data, 35 ) );
hb_BTreeInsert( pBTree, "cdntyzrf", hb_itemPutNL( data, 36 ) );
hb_BTreeInsert( pBTree, "iacblqrh", hb_itemPutNL( data, 37 ) );
hb_BTreeInsert( pBTree, "xvewqana", hb_itemPutNL( data, 38 ) );
hb_BTreeInsert( pBTree, "xmybqytj", hb_itemPutNL( data, 39 ) );
hb_BTreeInsert( pBTree, "dnowympf", hb_itemPutNL( data, 40 ) );
hb_BTreeInsert( pBTree, "smloihft", hb_itemPutNL( data, 41 ) );
hb_BTreeInsert( pBTree, "zumppmis", hb_itemPutNL( data, 42 ) );
hb_BTreeInsert( pBTree, "jirucnxu", hb_itemPutNL( data, 43 ) );
hb_BTreeInsert( pBTree, "ecdzikcv", hb_itemPutNL( data, 44 ) );
hb_BTreeInsert( pBTree, "slbwvnpg", hb_itemPutNL( data, 45 ) );
hb_BTreeInsert( pBTree, "yaftlkmz", hb_itemPutNL( data, 46 ) );
hb_BTreeInsert( pBTree, "blcepksd", hb_itemPutNL( data, 47 ) );
hb_BTreeInsert( pBTree, "xufowlpl", hb_itemPutNL( data, 48 ) );
hb_BTreeInsert( pBTree, "xegtjtqc", hb_itemPutNL( data, 49 ) );
hb_BTreeInsert( pBTree, "yplcqumq", hb_itemPutNL( data, 50 ) );
hb_BTreeInsert( pBTree, "vdoycauz", hb_itemPutNL( data, 51 ) );
hb_BTreeInsert( pBTree, "uhqkjuph", hb_itemPutNL( data, 52 ) );
hb_BTreeInsert( pBTree, "prllaeyi", hb_itemPutNL( data, 53 ) );
hb_BTreeInsert( pBTree, "ybzgmwzm", hb_itemPutNL( data, 54 ) );
hb_BTreeInsert( pBTree, "kkvyllnp", hb_itemPutNL( data, 55 ) );
hb_BTreeInsert( pBTree, "nberwsrb", hb_itemPutNL( data, 56 ) );
hb_BTreeInsert( pBTree, "wgetahua", hb_itemPutNL( data, 57 ) );
hb_BTreeInsert( pBTree, "yxcyehcv", hb_itemPutNL( data, 58 ) );
hb_BTreeInsert( pBTree, "oacormks", hb_itemPutNL( data, 59 ) );
hb_BTreeInsert( pBTree, "mcadkdxo", hb_itemPutNL( data, 60 ) );
hb_BTreeInsert( pBTree, "ycsalwqw", hb_itemPutNL( data, 61 ) );
hb_BTreeInsert( pBTree, "qmpysvjl", hb_itemPutNL( data, 62 ) );
hb_BTreeInsert( pBTree, "iqikamew", hb_itemPutNL( data, 63 ) );
hb_BTreeInsert( pBTree, "iaparrva", hb_itemPutNL( data, 64 ) );
hb_BTreeInsert( pBTree, "casbvtay", hb_itemPutNL( data, 65 ) );
hb_BTreeInsert( pBTree, "blaksexr", hb_itemPutNL( data, 66 ) );
hb_BTreeInsert( pBTree, "tbosrbql", hb_itemPutNL( data, 67 ) );
hb_BTreeInsert( pBTree, "ifkywsyt", hb_itemPutNL( data, 68 ) );
hb_BTreeInsert( pBTree, "gvklwevy", hb_itemPutNL( data, 69 ) );
hb_BTreeInsert( pBTree, "krpmpbud", hb_itemPutNL( data, 70 ) );
hb_BTreeInsert( pBTree, "rdvlwbwm", hb_itemPutNL( data, 71 ) );
hb_BTreeInsert( pBTree, "apnvdkww", hb_itemPutNL( data, 72 ) );
hb_BTreeInsert( pBTree, "euqdocvm", hb_itemPutNL( data, 73 ) );
hb_BTreeInsert( pBTree, "ksmkjcwp", hb_itemPutNL( data, 74 ) );
hb_BTreeInsert( pBTree, "bztgclzc", hb_itemPutNL( data, 75 ) );
hb_BTreeInsert( pBTree, "awkdnuxa", hb_itemPutNL( data, 76 ) );
hb_BTreeInsert( pBTree, "abavnpod", hb_itemPutNL( data, 77 ) );
hb_BTreeInsert( pBTree, "dvwvhjmh", hb_itemPutNL( data, 78 ) );
hb_BTreeInsert( pBTree, "dmfmivqb", hb_itemPutNL( data, 79 ) );
hb_BTreeInsert( pBTree, "ewsxanon", hb_itemPutNL( data, 80 ) );
hb_itemRelease( data );
}

View File

@@ -1,4 +1,4 @@
*
/*
* $Id$
*/
@@ -8,12 +8,86 @@
Procedure Main()
local n, a
local c
if fileattr( "test_1.out") = 1 + 32
setfattr( "test_1.out", 32 )
ferase( "test_1.out" )
endif
? "Harbour API test: in-memory"
n := hb_btreenew( , 2048, 90, HB_BTREE_READONLY + HB_BTREE_INMEMORY )
if n > 0
? "successfully opened"
insertdata( n, 100 )
? "# keys", hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )
? "skip to EOF test"
hb_btreegobottom( n )
? hb_btreekey( n ), hb_btreedata( n )
? hb_btreeskip( n, 1 )
? "skip to EOF test end"
? "Forward traversal"
hb_btreegotop( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if 1 <> hb_btreeskip( n, 1 )// .or. c == hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )-1
exit
endif
end
? "Forward traversal end"
?
? "Reverse traversal"
hb_btreegobottom( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if -1 <> hb_btreeskip( n, -1 )// .or. c == hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )-1
exit
endif
end
? "Reverse traversal end"
?
? "Test SEEK of 'cdntyzrf'"
? hb_btreeseek( n, "cdntyzrf" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of short key 'cd'"
? hb_btreeseek( n, "cd", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of an existing key 'cdntyzrf'"
? hb_btreeseek( n, "cdntyzrf", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of a missing key, that should force EOF ('zzzzzz')"
? hb_btreeseek( n, "zzzzzz" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
hb_btreeclose( n )
else
? "error / failure"
wait
endif
? "Harbour API test: in-memory end"
? "Harbour API test"
n := hb_btreenew( "test_1.out", 2048, 90, HB_BTREE_READONLY )
if n > 0
@@ -35,9 +109,10 @@ Procedure Main()
?
? "Forward traversal"
hb_btreegotop( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n )
if 2 <> hb_btreeskip( n, 2 )
? hb_btreekey( n ), hb_btreedata( n ), ++c
if 1 <> hb_btreeskip( n, 1 )
exit
endif
end
@@ -45,8 +120,9 @@ Procedure Main()
?
? "Reverse traversal"
hb_btreegobottom( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n )
? hb_btreekey( n ), hb_btreedata( n ), ++c
if -1 <> hb_btreeskip( n, -1 )
exit
endif
@@ -61,7 +137,7 @@ Procedure Main()
?
? "Test soft SEEK of a short key"
? hb_btreeseek( n, "cd", ,.t. )
? hb_btreeseek( n, "cd", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
@@ -121,87 +197,88 @@ Procedure Main()
return
static procedure insertdata( n )
hb_btreeinsert( n, "fuweqgsz", 1 )
hb_btreeinsert( n, "sjruexrd", 2 )
hb_btreeinsert( n, "fvveitnz", 3 )
hb_btreeinsert( n, "aqgksjxe", 4 )
hb_btreeinsert( n, "oonrehvj", 5 )
hb_btreeinsert( n, "gvowjwtr", 6 )
hb_btreeinsert( n, "xxidwtvn", 7 )
hb_btreeinsert( n, "rwjbxesd", 8 )
hb_btreeinsert( n, "yaznsaek", 9 )
hb_btreeinsert( n, "wbdhfkfy", 10 )
hb_btreeinsert( n, "lryaezia", 11 )
hb_btreeinsert( n, "tspmnrvk", 12 )
hb_btreeinsert( n, "hpxryhdj", 13 )
hb_btreeinsert( n, "sztcqaby", 14 )
hb_btreeinsert( n, "fcyzsqja", 15 )
hb_btreeinsert( n, "uccxumvg", 16 )
hb_btreeinsert( n, "amwuoout", 17 )
hb_btreeinsert( n, "yaytseln", 18 )
hb_btreeinsert( n, "sfiiozej", 19 )
hb_btreeinsert( n, "xuvsoljy", 20 )
hb_btreeinsert( n, "qmqjbedm", 21 )
hb_btreeinsert( n, "cctzzrkz", 22 )
hb_btreeinsert( n, "ikytgdon", 23 )
hb_btreeinsert( n, "pksobcwu", 24 )
hb_btreeinsert( n, "vmurindj", 25 )
hb_btreeinsert( n, "elvybqwg", 26 )
hb_btreeinsert( n, "ixchaztx", 27 )
hb_btreeinsert( n, "nzpztlhd", 28 )
hb_btreeinsert( n, "aucrchiw", 29 )
hb_btreeinsert( n, "munrytse", 30 )
hb_btreeinsert( n, "kqkhcmls", 31 )
hb_btreeinsert( n, "abqhurbi", 32 )
hb_btreeinsert( n, "ymrldckr", 33 )
hb_btreeinsert( n, "rhsmfflc", 34 )
hb_btreeinsert( n, "apyfkvee", 35 )
hb_btreeinsert( n, "cdntyzrf", 36 )
hb_btreeinsert( n, "iacblqrh", 37 )
hb_btreeinsert( n, "xvewqana", 38 )
hb_btreeinsert( n, "xmybqytj", 39 )
hb_btreeinsert( n, "dnowympf", 40 )
hb_btreeinsert( n, "smloihft", 41 )
hb_btreeinsert( n, "zumppmis", 42 )
hb_btreeinsert( n, "jirucnxu", 43 )
hb_btreeinsert( n, "ecdzikcv", 44 )
hb_btreeinsert( n, "slbwvnpg", 45 )
hb_btreeinsert( n, "yaftlkmz", 46 )
hb_btreeinsert( n, "blcepksd", 47 )
hb_btreeinsert( n, "xufowlpl", 48 )
hb_btreeinsert( n, "xegtjtqc", 49 )
hb_btreeinsert( n, "yplcqumq", 50 )
hb_btreeinsert( n, "vdoycauz", 51 )
hb_btreeinsert( n, "uhqkjuph", 52 )
hb_btreeinsert( n, "prllaeyi", 53 )
hb_btreeinsert( n, "ybzgmwzm", 54 )
hb_btreeinsert( n, "kkvyllnp", 55 )
hb_btreeinsert( n, "nberwsrb", 56 )
hb_btreeinsert( n, "wgetahua", 57 )
hb_btreeinsert( n, "yxcyehcv", 58 )
hb_btreeinsert( n, "oacormks", 59 )
hb_btreeinsert( n, "mcadkdxo", 60 )
hb_btreeinsert( n, "ycsalwqw", 61 )
hb_btreeinsert( n, "qmpysvjl", 62 )
hb_btreeinsert( n, "iqikamew", 63 )
hb_btreeinsert( n, "iaparrva", 64 )
hb_btreeinsert( n, "casbvtay", 65 )
hb_btreeinsert( n, "blaksexr", 66 )
hb_btreeinsert( n, "tbosrbql", 67 )
hb_btreeinsert( n, "ifkywsyt", 68 )
hb_btreeinsert( n, "gvklwevy", 69 )
hb_btreeinsert( n, "krpmpbud", 70 )
hb_btreeinsert( n, "rdvlwbwm", 71 )
hb_btreeinsert( n, "apnvdkww", 72 )
hb_btreeinsert( n, "euqdocvm", 73 )
hb_btreeinsert( n, "ksmkjcwp", 74 )
hb_btreeinsert( n, "bztgclzc", 75 )
hb_btreeinsert( n, "awkdnuxa", 76 )
hb_btreeinsert( n, "abavnpod", 77 )
hb_btreeinsert( n, "dvwvhjmh", 78 )
hb_btreeinsert( n, "dmfmivqb", 79 )
hb_btreeinsert( n, "ewsxanon", 80 )
static procedure insertdata( n, s )
if s == NIL ; s := 1; endif
hb_btreeinsert( n, "fuweqgsz", 1 / s )
hb_btreeinsert( n, "sjruexrd", 2 / s )
hb_btreeinsert( n, "fvveitnz", 3 / s )
hb_btreeinsert( n, "aqgksjxe", 4 / s )
hb_btreeinsert( n, "oonrehvj", 5 / s )
hb_btreeinsert( n, "gvowjwtr", 6 / s )
hb_btreeinsert( n, "xxidwtvn", 7 / s )
hb_btreeinsert( n, "rwjbxesd", 8 / s )
hb_btreeinsert( n, "yaznsaek", 9 / s )
hb_btreeinsert( n, "wbdhfkfy", 10 / s )
hb_btreeinsert( n, "lryaezia", 11 / s )
hb_btreeinsert( n, "tspmnrvk", 12 / s )
hb_btreeinsert( n, "hpxryhdj", 13 / s )
hb_btreeinsert( n, "sztcqaby", 14 / s )
hb_btreeinsert( n, "fcyzsqja", 15 / s )
hb_btreeinsert( n, "uccxumvg", 16 / s )
hb_btreeinsert( n, "amwuoout", 17 / s )
hb_btreeinsert( n, "yaytseln", 18 / s )
hb_btreeinsert( n, "sfiiozej", 19 / s )
hb_btreeinsert( n, "xuvsoljy", 20 / s )
hb_btreeinsert( n, "qmqjbedm", 21 / s )
hb_btreeinsert( n, "cctzzrkz", 22 / s )
hb_btreeinsert( n, "ikytgdon", 23 / s )
hb_btreeinsert( n, "pksobcwu", 24 / s )
hb_btreeinsert( n, "vmurindj", 25 / s )
hb_btreeinsert( n, "elvybqwg", 26 / s )
hb_btreeinsert( n, "ixchaztx", 27 / s )
hb_btreeinsert( n, "nzpztlhd", 28 / s )
hb_btreeinsert( n, "aucrchiw", 29 / s )
hb_btreeinsert( n, "munrytse", 30 / s )
hb_btreeinsert( n, "kqkhcmls", 31 / s )
hb_btreeinsert( n, "abqhurbi", 32 / s )
hb_btreeinsert( n, "ymrldckr", 33 / s )
hb_btreeinsert( n, "rhsmfflc", 34 / s )
hb_btreeinsert( n, "apyfkvee", 35 / s )
hb_btreeinsert( n, "cdntyzrf", 36 / s )
hb_btreeinsert( n, "iacblqrh", 37 / s )
hb_btreeinsert( n, "xvewqana", 38 / s )
hb_btreeinsert( n, "xmybqytj", 39 / s )
hb_btreeinsert( n, "dnowympf", 40 / s )
hb_btreeinsert( n, "smloihft", 41 / s )
hb_btreeinsert( n, "zumppmis", 42 / s )
hb_btreeinsert( n, "jirucnxu", 43 / s )
hb_btreeinsert( n, "ecdzikcv", 44 / s )
hb_btreeinsert( n, "slbwvnpg", 45 / s )
hb_btreeinsert( n, "yaftlkmz", 46 / s )
hb_btreeinsert( n, "blcepksd", 47 / s )
hb_btreeinsert( n, "xufowlpl", 48 / s )
hb_btreeinsert( n, "xegtjtqc", 49 / s )
hb_btreeinsert( n, "yplcqumq", 50 / s )
hb_btreeinsert( n, "vdoycauz", 51 / s )
hb_btreeinsert( n, "uhqkjuph", 52 / s )
hb_btreeinsert( n, "prllaeyi", 53 / s )
hb_btreeinsert( n, "ybzgmwzm", 54 / s )
hb_btreeinsert( n, "kkvyllnp", 55 / s )
hb_btreeinsert( n, "nberwsrb", 56 / s )
hb_btreeinsert( n, "wgetahua", 57 / s )
hb_btreeinsert( n, "yxcyehcv", 58 / s )
hb_btreeinsert( n, "oacormks", 59 / s )
hb_btreeinsert( n, "mcadkdxo", 60 / s )
hb_btreeinsert( n, "ycsalwqw", 61 / s )
hb_btreeinsert( n, "qmpysvjl", 62 / s )
hb_btreeinsert( n, "iqikamew", 63 / s )
hb_btreeinsert( n, "iaparrva", 64 / s )
hb_btreeinsert( n, "casbvtay", 65 / s )
hb_btreeinsert( n, "blaksexr", 66 / s )
hb_btreeinsert( n, "tbosrbql", 67 / s )
hb_btreeinsert( n, "ifkywsyt", 68 / s )
hb_btreeinsert( n, "gvklwevy", 69 / s )
hb_btreeinsert( n, "krpmpbud", 70 / s )
hb_btreeinsert( n, "rdvlwbwm", 71 / s )
hb_btreeinsert( n, "apnvdkww", 72 / s )
hb_btreeinsert( n, "euqdocvm", 73 / s )
hb_btreeinsert( n, "ksmkjcwp", 74 / s )
hb_btreeinsert( n, "bztgclzc", 75 / s )
hb_btreeinsert( n, "awkdnuxa", 76 / s )
hb_btreeinsert( n, "abavnpod", 77 / s )
hb_btreeinsert( n, "dvwvhjmh", 78 / s )
hb_btreeinsert( n, "dmfmivqb", 79 / s )
hb_btreeinsert( n, "ewsxanon", 80 / s )
return
/*

View File

@@ -31,7 +31,7 @@ Procedure TTest()
n:gotop()
while .t.
? n:key(), n:data()
if 2 <> n:skip( 2 )
if 1 <> n:skip( 1 )
exit
endif
end