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

📄 tcutil.h

📁 Tokyo Cabinet的Tokyo Cabinet 是一个DBM的实现。这里的数据库由一系列key-value对的记录构成。key和value都可以是任意长度的字节序列,既可以是二进制也可以是字符
💻 H
📖 第 1 页 / 共 5 页
字号:
   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string. */const void *tctreeget(TCTREE *tree, const void *kbuf, int ksiz, int *sp);/* Retrieve a string record in a tree object.   `tree' specifies the tree object.   `kstr' specifies the string of the key.   If successful, the return value is the string of the value of the corresponding record.   `NULL' is returned when no record corresponds. */const char *tctreeget2(TCTREE *tree, const char *kstr);/* Initialize the iterator of a tree object.   `tree' specifies the tree object.   The iterator is used in order to access the key of every record stored in the tree object. */void tctreeiterinit(TCTREE *tree);/* Initialize the iterator of a tree object in front of records corresponding a key.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   The iterator is set to the first record corresponding the key or the next substitute if   completely matching record does not exist. */void tctreeiterinit2(TCTREE *tree, const void *kbuf, int ksiz);/* Initialize the iterator of a tree object in front of records corresponding a key string.   `tree' specifies the tree object.   `kstr' specifies the string of the key.   The iterator is set to the first record corresponding the key or the next substitute if   completely matching record does not exist. */void tctreeiterinit3(TCTREE *tree, const char *kstr);/* Get the next key of the iterator of a tree object.   `tree' specifies the tree object.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   If successful, the return value is the pointer to the region of the next key, else, it is   `NULL'.  `NULL' is returned when no record can be fetched from the iterator.   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string.   The order of iteration is assured to be ascending of the keys. */const void *tctreeiternext(TCTREE *tree, int *sp);/* Get the next key string of the iterator of a tree object.   `tree' specifies the tree object.   If successful, the return value is the pointer to the region of the next key, else, it is   `NULL'.  `NULL' is returned when no record can be fetched from the iterator.   The order of iteration is assured to be ascending of the keys. */const char *tctreeiternext2(TCTREE *tree);/* Get the number of records stored in a tree object.   `tree' specifies the tree object.   The return value is the number of the records stored in the tree object. */uint64_t tctreernum(const TCTREE *tree);/* Get the total size of memory used in a tree object.   `tree' specifies the tree object.   The return value is the total size of memory used in a tree object. */uint64_t tctreemsiz(const TCTREE *tree);/* Create a list object containing all keys in a tree object.   `tree' specifies the tree object.   The return value is the new list object containing all keys in the tree object.   Because the object of the return value is created with the function `tclistnew', it should   be deleted with the function `tclistdel' when it is no longer in use. */TCLIST *tctreekeys(const TCTREE *tree);/* Create a list object containing all values in a tree object.   `tree' specifies the tree object.   The return value is the new list object containing all values in the tree object.   Because the object of the return value is created with the function `tclistnew', it should   be deleted with the function `tclistdel' when it is no longer in use. */TCLIST *tctreevals(const TCTREE *tree);/* Add an integer to a record in a tree object.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `num' specifies the additional value.   The return value is the summation value.   If the corresponding record exists, the value is treated as an integer and is added to.  If no   record corresponds, a new record of the additional value is stored. */int tctreeaddint(TCTREE *tree, const void *kbuf, int ksiz, int num);/* Add a real number to a record in a tree object.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `num' specifies the additional value.   The return value is the summation value.   If the corresponding record exists, the value is treated as a real number and is added to.  If   no record corresponds, a new record of the additional value is stored. */double tctreeadddouble(TCTREE *tree, const void *kbuf, int ksiz, double num);/* Clear a tree object.   `tree' specifies the tree object.   All records are removed. */void tctreeclear(TCTREE *tree);/* Remove fringe records of a tree object.   `tree' specifies the tree object.   `num' specifies the number of records to be removed. */void tctreecutfringe(TCTREE *tree, int num);/* Serialize a tree object into a byte array.   `tree' specifies the tree object.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   The return value is the pointer to the region of the result serial region.   Because the region of the return value is allocated with the `malloc' call, it should be   released with the `free' call when it is no longer in use. */void *tctreedump(const TCTREE *tree, int *sp);/* Create a tree object from a serialized byte array.   `ptr' specifies the pointer to the region of serialized byte array.   `size' specifies the size of the region.   `cmp' specifies the pointer to the custom comparison function.   `cmpop' specifies an arbitrary pointer to be given as a parameter of the comparison function.   If it is not needed, `NULL' can be specified.   The return value is a new tree object.   Because the object of the return value is created with the function `tctreenew', it should be   deleted with the function `tctreedel' when it is no longer in use. */TCTREE *tctreeload(const void *ptr, int size, TCCMP cmp, void *cmpop);/************************************************************************************************* * ordered tree (for experts) *************************************************************************************************//* Store a record into a tree object without balancing nodes.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `vbuf' specifies the pointer to the region of the value.   `vsiz' specifies the size of the region of the value.   If a record with the same key exists in the tree, it is overwritten.  The structure of the   tree is not modifed by this function. */void tctreeput3(TCTREE *tree, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a new record into a tree object without balancing nodes.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `vbuf' specifies the pointer to the region of the value.   `vsiz' specifies the size of the region of the value.   If successful, the return value is true, else, it is false.   If a record with the same key exists in the tree, this function has no effect.  The structure   of the tree is not modifed by this function. */bool tctreeputkeep3(TCTREE *tree, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Concatenate a value at the existing record in a tree object without balancing nodes.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `vbuf' specifies the pointer to the region of the value.   `vsiz' specifies the size of the region of the value.   If there is no corresponding record, a new record is created.  The structure of the tree is   not modifed by this function. */void tctreeputcat3(TCTREE *tree, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Retrieve a record in a tree object without balancing nodes.   `tree' specifies the tree object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   If successful, the return value is the pointer to the region of the value of the   corresponding record.  `NULL' is returned when no record corresponds.   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string.  The structure of the tree is not   modifed by this function. */const void *tctreeget3(const TCTREE *tree, const void *kbuf, int ksiz, int *sp);/* Get the value bound to the key fetched from the iterator of a tree object.   `kbuf' specifies the pointer to the region of the iteration key.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   The return value is the pointer to the region of the value of the corresponding record.   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string. */const void *tctreeiterval(const void *kbuf, int *sp);/* Get the value string bound to the key fetched from the iterator of a tree object.   `kstr' specifies the string of the iteration key.   The return value is the pointer to the region of the value of the corresponding record. */const char *tctreeiterval2(const char *kstr);/* Create an array of strings of all keys in a tree object.   `tree' specifies the tree object.   `np' specifies the pointer to a variable into which the number of elements of the return value   is assigned.   The return value is the pointer to the array of all string keys in the tree object.   Because the region of the return value is allocated with the `malloc' call, it should be   released with the `free' call if when is no longer in use.  Note that elements of the array   point to the inner objects, whose life duration is synchronous with the tree object. */const char **tctreekeys2(const TCTREE *tree, int *np);/* Create an array of strings of all values in a tree object.   `tree' specifies the tree object.   `np' specifies the pointer to a variable into which the number of elements of the return value   is assigned.   The return value is the pointer to the array of all string values in the tree object.   Because the region of the return value is allocated with the `malloc' call, it should be   released with the `free' call if when is no longer in use.  Note that elements of the array   point to the inner objects, whose life duration is synchronous with the tree object. */const char **tctreevals2(const TCTREE *tree, int *np);/* Extract a tree record from a serialized byte array.   `ptr' specifies the pointer to the region of serialized byte array.   `size' specifies the size of the region.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   If successful, the return value is the pointer to the region of the value of the   corresponding record.  `NULL' is returned when no record corresponds.   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string. */void *tctreeloadone(const void *ptr, int size, const void *kbuf, int ksiz, int *sp);/************************************************************************************************* * on-memory hash database *************************************************************************************************/typedef struct {                         /* type of structure for a on-memory hash database */  void **mmtxs;                          /* mutexes for method */  void *imtx;                            /* mutex for iterator */  TCMAP **maps;                          /* internal map objects */  int iter;                              /* index of maps for the iterator */} TCMDB;/* Create an on-memory hash database object.   The return value is the new on-memory hash database object.   The object can be shared by plural threads because of the internal mutex. */TCMDB *tcmdbnew(void);/* Create an on-memory hash database object with specifying the number of the buckets.   `bnum' specifies the number of the buckets.   The return value is the new on-memory hash database object.   The object can be shared by plural threads because of the internal mutex. */TCMDB *tcmdbnew2(uint32_t bnum);/* Delete an on-memory hash database object.   `mdb' specifies the on-memory hash database object. */void tcmdbdel(TCMDB *mdb);/* Store a record into an on-memory hash database object.   `mdb' specifies the on-memory hash database object.   `kbu

⌨️ 快捷键说明

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