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

📄 tcutil.h

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 H
📖 第 1 页 / 共 5 页
字号:
   the return value can be treated as a character string.  If `index' is equal to or more than   the number of elements, the return value is `NULL'. */const void *tclistval(const TCLIST *list, int index, int *sp);/* Get the string of an element of a list object.   `list' specifies the list object.   `index' specifies the index of the element.   The return value is the string of the value.   If `index' is equal to or more than the number of elements, the return value is `NULL'. */const char *tclistval2(const TCLIST *list, int index);/* Add an element at the end of a list object.   `list' specifies the list object.   `ptr' specifies the pointer to the region of the new element.   `size' specifies the size of the region. */void tclistpush(TCLIST *list, const void *ptr, int size);/* Add a string element at the end of a list object.   `list' specifies the list object.   `str' specifies the string of the new element. */void tclistpush2(TCLIST *list, const char *str);/* Add an allocated element at the end of a list object.   `list' specifies the list object.   `ptr' specifies the pointer to the region allocated with `malloc' call.   `size' specifies the size of the region.   Note that the specified region is released when the object is deleted. */void tclistpushmalloc(TCLIST *list, void *ptr, int size);/* Remove an element of the end of a list object.   `list' specifies the list 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 removed element.   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.  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.  If the list is empty, the return value is `NULL'. */void *tclistpop(TCLIST *list, int *sp);/* Remove a string element of the end of a list object.   `list' specifies the list object.   The return value is the string of the removed element.   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.  If the list is empty, the return   value is `NULL'. */char *tclistpop2(TCLIST *list);/* Add an element at the top of a list object.   `list' specifies the list object.   `ptr' specifies the pointer to the region of the new element.   `size' specifies the size of the region. */void tclistunshift(TCLIST *list, const void *ptr, int size);/* Add a string element at the top of a list object.   `list' specifies the list object.   `str' specifies the string of the new element. */void tclistunshift2(TCLIST *list, const char *str);/* Remove an element of the top of a list object.   `list' specifies the list 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 removed element.   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.  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.  If the list is empty, the return value is `NULL'. */void *tclistshift(TCLIST *list, int *sp);/* Remove a string element of the top of a list object.   `list' specifies the list object.   The return value is the string of the removed element.   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.  If the list is empty, the return   value is `NULL'. */char *tclistshift2(TCLIST *list);/* Add an element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the new element.   `ptr' specifies the pointer to the region of the new element.   `size' specifies the size of the region.   If `index' is equal to or more than the number of elements, this function has no effect. */void tclistinsert(TCLIST *list, int index, const void *ptr, int size);/* Add a string element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the new element.   `str' specifies the string of the new element.   If `index' is equal to or more than the number of elements, this function has no effect. */void tclistinsert2(TCLIST *list, int index, const char *str);/* Remove an element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the element to be removed.   `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 removed element.   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.  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.  If `index' is equal to or more than the number of elements, no element   is removed and the return value is `NULL'. */void *tclistremove(TCLIST *list, int index, int *sp);/* Remove a string element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the element to be removed.   The return value is the string of the removed element.   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.  If `index' is equal to or more   than the number of elements, no element is removed and the return value is `NULL'. */char *tclistremove2(TCLIST *list, int index);/* Overwrite an element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the element to be overwritten.   `ptr' specifies the pointer to the region of the new content.   `size' specifies the size of the new content.   If `index' is equal to or more than the number of elements, this function has no effect. */void tclistover(TCLIST *list, int index, const void *ptr, int size);/* Overwrite a string element at the specified location of a list object.   `list' specifies the list object.   `index' specifies the index of the element to be overwritten.   `str' specifies the string of the new content.   If `index' is equal to or more than the number of elements, this function has no effect. */void tclistover2(TCLIST *list, int index, const char *str);/* Sort elements of a list object in lexical order.   `list' specifies the list object. */void tclistsort(TCLIST *list);/* Sort elements of a list object in case-insensitive lexical order.   `list' specifies the list object. */void tclistsortci(TCLIST *list);/* Sort elements of a list object by an arbitrary comparison function.   `list' specifies the list object.   `cmp' specifies the pointer to the comparison function.  The structure TCLISTDATUM has the   member "ptr" which is the pointer to the region of the element, and the member "size" which is   the size of the region. */void tclistsortex(TCLIST *list, int (*cmp)(const TCLISTDATUM *, const TCLISTDATUM *));/* Search a list object for an element using liner search.   `list' specifies the list object.   `ptr' specifies the pointer to the region of the key.   `size' specifies the size of the region.   The return value is the index of a corresponding element or -1 if there is no corresponding   element.   If two or more elements correspond, the former returns. */int tclistlsearch(const TCLIST *list, const void *ptr, int size);/* Search a list object for an element using binary search.   `list' specifies the list object.  It should be sorted in lexical order.   `ptr' specifies the pointer to the region of the key.   `size' specifies the size of the region.   The return value is the index of a corresponding element or -1 if there is no corresponding   element.   If two or more elements correspond, which returns is not defined. */int tclistbsearch(const TCLIST *list, const void *ptr, int size);/* Clear a list object.   `list' specifies the list object.   All elements are removed. */void tclistclear(TCLIST *list);/* Serialize a list object into a byte array.   `list' specifies the list 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 *tclistdump(const TCLIST *list, int *sp);/* Create a list object from a serialized byte array.   `ptr' specifies the pointer to the region of serialized byte array.   `size' specifies the size of the region.   The return value is a new list 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 *tclistload(const void *ptr, int size);/************************************************************************************************* * hash map *************************************************************************************************/typedef struct _TCMAPREC {               /* type of structure for an element of a map */  int ksiz;                              /* size of the region of the key */  int vsiz;                              /* size of the region of the value */  unsigned int hash;                     /* second hash value */  struct _TCMAPREC *left;                /* pointer to the left child */  struct _TCMAPREC *right;               /* pointer to the right child */  struct _TCMAPREC *prev;                /* pointer to the previous element */  struct _TCMAPREC *next;                /* pointer to the next element */} TCMAPREC;typedef struct {                         /* type of structure for a map */  TCMAPREC **buckets;                    /* bucket array */  TCMAPREC *first;                       /* pointer to the first element */  TCMAPREC *last;                        /* pointer to the last element */  TCMAPREC *cur;                         /* pointer to the current element */  uint32_t bnum;                         /* number of buckets */  uint64_t rnum;                         /* number of records */  uint64_t msiz;                         /* total size of records */} TCMAP;/* Create a map object.   The return value is the new map object. */TCMAP *tcmapnew(void);/* Create a map object with specifying the number of the buckets.   `bnum' specifies the number of the buckets.   The return value is the new map object. */TCMAP *tcmapnew2(uint32_t bnum);/* Copy a map object.   `map' specifies the map object.   The return value is the new map object equivalent to the specified object. */TCMAP *tcmapdup(const TCMAP *map);/* Delete a map object.   `map' specifies the map object.   Note that the deleted object and its derivatives can not be used anymore. */void tcmapdel(TCMAP *map);/* Store a record into a map object.   `map' specifies the map 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 map, it is overwritten. */void tcmapput(TCMAP *map, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a string record into a map object.   `map' specifies the map object.   `kstr' specifies the string of the key.   `vstr' specifies the string of the value.   If a record with the same key exists in the map, it is overwritten. */void tcmapput2(TCMAP *map, const char *kstr, const char *vstr);/* Store a record of the value of two regions into a map object.   `map' specifies the map object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.

⌨️ 快捷键说明

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