📄 tcutil.h
字号:
`fvbuf' specifies the pointer to the former region of the value. `fvsiz' specifies the size of the former region of the value. `lvbuf' specifies the pointer to the latter region of the value. `lvsiz' specifies the size of the latter region of the value. If a record with the same key exists in the map, it is overwritten. */void tcmapput3(TCMAP *map, const void *kbuf, int ksiz, const void *fvbuf, int fvsiz, const void *lvbuf, int lvsiz);/* Store a new 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 successful, the return value is true, else, it is false. If a record with the same key exists in the map, this function has no effect. */bool tcmapputkeep(TCMAP *map, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Store a new 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 successful, the return value is true, else, it is false. If a record with the same key exists in the map, this function has no effect. */bool tcmapputkeep2(TCMAP *map, const char *kstr, const char *vstr);/* Concatenate a value at the end of the value of the existing record in 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 there is no corresponding record, a new record is created. */void tcmapputcat(TCMAP *map, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Concatenate a string value at the end of the value of the existing record in a map object. `map' specifies the map object. `kstr' specifies the string of the key. `vstr' specifies the string of the value. If there is no corresponding record, a new record is created. */void tcmapputcat2(TCMAP *map, const char *kstr, const char *vstr);/* Remove a record of 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. If successful, the return value is true. False is returned when no record corresponds to the specified key. */bool tcmapout(TCMAP *map, const void *kbuf, int ksiz);/* Remove a string record of a map object. `map' specifies the map object. `kstr' specifies the string of the key. If successful, the return value is true. False is returned when no record corresponds to the specified key. */bool tcmapout2(TCMAP *map, const char *kstr);/* Retrieve a record in 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. `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. */const void *tcmapget(const TCMAP *map, const void *kbuf, int ksiz, int *sp);/* Retrieve a string record in a map object. `map' specifies the map 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 *tcmapget2(const TCMAP *map, const char *kstr);/* Retrieve a semivolatile record in 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. `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 internal region of the returned record is moved to the tail so that the record will survive for a time under LRU cache algorithm removing records from the head. */const void *tcmapget3(TCMAP *map, const void *kbuf, int ksiz, int *sp);/* Move a record to the edge of a map object. `map' specifies the map object. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. `head' specifies the destination which is head if it is true or tail if else. If successful, the return value is true. False is returned when no record corresponds to the specified key. */bool tcmapmove(TCMAP *map, const void *kbuf, int ksiz, bool head);/* Move a string record to the edge of a map object. `map' specifies the map object. `kstr' specifies the string of a key. `head' specifies the destination which is head if it is true or tail if else. If successful, the return value is true. False is returned when no record corresponds to the specified key. */bool tcmapmove2(TCMAP *map, const char *kstr, bool head);/* Initialize the iterator of a map object. `map' specifies the map object. The iterator is used in order to access the key of every record stored in the map object. */void tcmapiterinit(TCMAP *map);/* Get the next key of the iterator of a map object. `map' specifies the map 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 the same as the stored order. */const void *tcmapiternext(TCMAP *map, int *sp);/* Get the next key string of the iterator of a map object. `map' specifies the map 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 the same as the stored order. */const char *tcmapiternext2(TCMAP *map);/* Get the value bound to the key fetched from the iterator of a map 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 *tcmapiterval(const void *kbuf, int *sp);/* Get the value string bound to the key fetched from the iterator of a map 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 *tcmapiterval2(const char *kstr);/* Get the number of records stored in a map object. `map' specifies the map object. The return value is the number of the records stored in the map object. */uint64_t tcmaprnum(const TCMAP *map);/* Get the total size of memory used in a map object. `map' specifies the map object. The return value is the total size of memory used in a map object. */uint64_t tcmapmsiz(const TCMAP *map);/* Create a list object containing all keys in a map object. `map' specifies the map object. The return value is the new list object containing all keys in the map 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 *tcmapkeys(const TCMAP *map);/* Create an array of strings of all keys in a map object. `map' specifies the map 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 map 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 map object. */const char **tcmapkeys2(const TCMAP *map, int *np);/* Create a list object containing all values in a map object. `map' specifies the map object. The return value is the new list object containing all values in the map 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 *tcmapvals(const TCMAP *map);/* Create an array of strings of all values in a map object. `map' specifies the map 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 map 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 map object. */const char **tcmapvals2(const TCMAP *map, int *np);/* Add an integer to a record in 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. `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 tcmapaddint(TCMAP *map, const void *kbuf, int ksiz, int num);/* Add a real number to a record in 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. `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 tcmapadddouble(TCMAP *map, const void *kbuf, int ksiz, double num);/* Clear a map object. `map' specifies the map object. All records are removed. */void tcmapclear(TCMAP *map);/* Remove front records of a map object. `map' specifies the map object. `num' specifies the number of records to be removed. */void tcmapcutfront(TCMAP *map, int num);/* Serialize a map object into a byte array. `map' specifies the map 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 *tcmapdump(const TCMAP *map, int *sp);/* Create a map 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 map object. Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use. */TCMAP *tcmapload(const void *ptr, int size);/* Extract a map 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 *tcmaploadone(const void *ptr, int size, const void *kbuf, int ksiz, int *sp);/************************************************************************************************* * ordered tree *************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -