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

📄 tcutilex.c

📁 Tokyo Cabinet的Tokyo Cabinet 是一个DBM的实现。这里的数据库由一系列key-value对的记录构成。key和value都可以是任意长度的字节序列,既可以是二进制也可以是字符
💻 C
字号:
#include <tcutil.h>#include <stdlib.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>int main(int argc, char **argv){  { /* example to use an extensible string object */    TCXSTR *xstr;    /* create the object */    xstr = tcxstrnew();    /* concatenate strings */    tcxstrcat2(xstr, "hop");    tcxstrcat2(xstr, "step");    tcxstrcat2(xstr, "jump");    /* print the size and the content */    printf("%d:%s\n", tcxstrsize(xstr), (char *)tcxstrptr(xstr));    /* delete the object */    tcxstrdel(xstr);  }  { /* example to use a list object */    TCLIST *list;    int i;    /* create the object */    list = tclistnew();    /* add strings to the tail */    tclistpush2(list, "hop");    tclistpush2(list, "step");    tclistpush2(list, "jump");    /* print all elements */    for(i = 0; i < tclistnum(list); i++){      printf("%d:%s\n", i, tclistval2(list, i));    }    /* delete the object */    tclistdel(list);  }  { /* example to use a map object */    TCMAP *map;    const char *key;    /* create the object */    map = tcmapnew();    /* add records */    tcmapput2(map, "foo", "hop");    tcmapput2(map, "bar", "step");    tcmapput2(map, "baz", "jump");    /* print all records */    tcmapiterinit(map);    while((key = tcmapiternext2(map)) != NULL){      printf("%s:%s\n", key, tcmapget2(map, key));    }    /* delete the object */    tcmapdel(map);  }  { /* example to use a tree object */    TCTREE *tree;    const char *key;    /* create the object */    tree = tctreenew();    /* add records */    tctreeput2(tree, "foo", "hop");    tctreeput2(tree, "bar", "step");    tctreeput2(tree, "baz", "jump");    /* print all records */    tctreeiterinit(tree);    while((key = tctreeiternext2(tree)) != NULL){      printf("%s:%s\n", key, tctreeget2(tree, key));    }    /* delete the object */    tctreedel(tree);  }  return 0;}

⌨️ 快捷键说明

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