⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pbl.h

📁 B树算法实现
💻 H
📖 第 1 页 / 共 2 页
字号:
        { (ITEM)->NEXT->PREV = (ITEM)->PREV; }\    else\        { (TAIL) = (ITEM)->PREV; }\    if( (ITEM)->PREV )\        { (ITEM)->PREV->NEXT = (ITEM)->NEXT; }\    else\        { (HEAD) = (ITEM)->NEXT; }\}/* * SOME MACROS FOR KEY FILE READ FUNCTIONS *//** * set the current record to the first record of the file */#define pblKfFirst( KF, K, L ) pblKfGetAbs( KF,  0, K, L )/** * set the current record to the last record of the file */#define  pblKfLast( KF, K, L ) pblKfGetAbs( KF, -1, K, L )/** * set the current record to the next record of the file */#define  pblKfNext( KF, K, L ) pblKfGetRel( KF,  1, K, L )/** * set the current record to the previous record of the file */#define  pblKfPrev( KF, K, L ) pblKfGetRel( KF, -1, K, L )/** * return the datalen of the current record */#define  pblKfThis( KF, K, L ) pblKfGetRel( KF,  0, K, L )/*****************************************************************************//* typedefs                                                                  *//*****************************************************************************/struct pblHashTable_s{    char * magic;};/**  * the hash table type the pblHt* functions are dealing with,  * @doc the details of the structure are hidden from the user  */typedef struct pblHashTable_s pblHashTable_t;struct pblKeyFile_s{    char * magic;};/**  * the key file type the pblKf* functions are dealing with,  * @doc the details of the structure are hidden from the user  */typedef struct pblKeyFile_s pblKeyFile_t;struct pblIsamFile_s{    char * magic;};/**  * the ISAM file type the pblIsam* functions are dealing with,  * @doc the details of the structure are hidden from the user  */typedef struct pblIsamFile_s pblIsamFile_t;/*****************************************************************************//* variable declarations                                                     *//*****************************************************************************//**  * integer value used for returning error codes  */extern int    pbl_errno;/**  * character buffer used for returning error strings  */extern char * pbl_errstr;/*****************************************************************************//* function declarations                                                     *//*****************************************************************************/extern void * pbl_malloc( char * tag, size_t size );extern void * pbl_malloc0( char * tag, size_t size );extern void * pbl_memdup( char * tag, void * data, size_t size );extern void * pbl_mem2dup( char * tag, void * mem1, size_t len1,                           void * mem2, size_t len2 );extern int    pbl_memcmplen( void * left, size_t llen,                             void * right, size_t rlen );extern int    pbl_memcmp( void * left, size_t llen, void * right, size_t rlen );extern size_t pbl_memlcpy( void * to, size_t tolen, void * from, size_t n );extern void   pbl_ShortToBuf( unsigned char * buf, int s );extern int    pbl_BufToShort( unsigned char * buf );extern void   pbl_LongToBuf( unsigned char * buf, long l );extern long   pbl_BufToLong( unsigned char * buf );extern int    pbl_LongToVarBuf( unsigned char * buffer, unsigned long value );extern int    pbl_VarBufToLong( unsigned char * buffer, long * value );extern int    pbl_LongSize( unsigned long value );extern int    pbl_VarBufSize( unsigned char * buffer );extern pblHashTable_t * pblHtCreate( );extern int    pblHtInsert  ( pblHashTable_t * h, void * key, size_t keylen,                             void * dataptr);extern void * pblHtLookup  ( pblHashTable_t * h, void * key, size_t keylen );extern void * pblHtFirst   ( pblHashTable_t * h );extern void * pblHtNext    ( pblHashTable_t * h );extern void * pblHtCurrent ( pblHashTable_t * h );extern int    pblHtRemove  ( pblHashTable_t * h, void * key, size_t keylen );extern int    pblHtDelete  ( pblHashTable_t * h );/* * FUNCTIONS ON KEY FILES */ int            pblKfInit  ( int nblocks );extern pblKeyFile_t * pblKfCreate( char * path, void * filesettag );extern pblKeyFile_t * pblKfOpen  ( char * path, int update, void * filesettag );extern int            pblKfClose ( pblKeyFile_t * k );extern int            pblKfFlush ( pblKeyFile_t * k );extern int            pblKfStartTransaction( pblKeyFile_t * k );extern int            pblKfCommit( pblKeyFile_t * k, int rollback );extern int            pblKfSavePosition( pblKeyFile_t * k );extern int            pblKfRestorePosition( pblKeyFile_t * k );extern void pblKfSetCompareFunction(pblKeyFile_t * k,             /** key file to set compare function for  */int ( *keycompare )           /** compare function to set               */    (                void* left,   /** "left" buffer for compare             */                      size_t llen,  /** length of that buffer                 */                      void* right,  /** "right" buffer for compare            */                      size_t rlen   /** length of that buffer                 */    )                );/* * WRITE FUNCTIONS ON RECORDS, DELETE AND UPDATE WORK ON CURRENT RECORD */extern int pblKfInsert(pblKeyFile_t   * k,unsigned char  * key,int              keylen,unsigned char  * data,long             datalen);extern int pblKfDelete( pblKeyFile_t * k );extern int pblKfUpdate(pblKeyFile_t   * k,unsigned char  * data,long             datalen);/* * KEY FILE READ FUNCTIONS ON RECORDS */extern long pblKfFind(pblKeyFile_t   * k,int              mode,unsigned char  * skey,int              skeylen,unsigned char  * okey,int            * okeylen);extern long pblKfRead(pblKeyFile_t  * k,unsigned char * data,long            datalen);/* * FUNCTIONS ACTUALLY ONLY TO BE USED THROUGH THE MAKROS DEFINED BELOW * * however, the functions work, but they are not very fast * * pblKfGetRel - positions relative to the current record to any other *               record of the file, interface is like pblKfNext * * pblKfGetAbs - positions absolute to the absindex 'th record of the file, *               -1L means last, interface is like pblKfFirst */extern long pblKfGetRel( pblKeyFile_t * k, long relindex,                         char *okey, int *okeylen);extern long pblKfGetAbs( pblKeyFile_t * k, long absindex,                         char *okey, int *okeylen);/* * FUNCTIONS ON ISAM FILES */extern int pblIsamClose( pblIsamFile_t * isamfile );extern int pblIsamFlush( pblIsamFile_t * isamfile );extern int pblIsamDelete( pblIsamFile_t * isamfile );extern pblIsamFile_t * pblIsamOpen(char        * path,int           update,void        * filesettag,int           nkeys,char       ** keyfilenames,int         * keydup);extern int pblIsamInsert(pblIsamFile_t * isamfile,unsigned char * allkeys,int             allkeyslen,unsigned char * data,long            datalen);extern int pblIsamFind(pblIsamFile_t  * isamfile,int              mode,int              index,unsigned char  * skey,int              skeylen,unsigned char  * okey);extern int pblIsamGet(pblIsamFile_t  * isamfile,int              which,int              index,unsigned char  * okey);extern int pblIsamReadKey(pblIsamFile_t  * isamfile,int              index,unsigned char  * okey);extern long pblIsamReadDatalen( pblIsamFile_t * isamfile );extern long pblIsamReadData(pblIsamFile_t * isamfile,unsigned char * buffer,long            bufferlen);extern long pblIsamUpdateData(pblIsamFile_t * isamfile,unsigned char * data,long            datalen);extern int pblIsamUpdateKey(pblIsamFile_t  * isamfile,int              index,unsigned char  * ukey,int              ukeylen);extern int pblIsamStartTransaction( int nfiles, pblIsamFile_t ** isamfiles );extern int pblIsamCommit( int nfiles, pblIsamFile_t ** isamfiles, int rollback);#ifdef __cplusplus}#endif#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -