• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dict_new函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dict_new函数的典型用法代码示例。如果您正苦于以下问题:C++ dict_new函数的具体用法?C++ dict_new怎么用?C++ dict_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dict_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cli_cmd_uuid_reset_cbk

int
cli_cmd_uuid_reset_cbk (struct cli_state *state, struct cli_cmd_word *word,
                        const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        int                     sent = 0;
        int                     parse_error = 0;
        gf_answer_t             answer = GF_ANSWER_NO;
        char                    *question = NULL;
        cli_local_t             *local = NULL;
        dict_t                  *dict  = NULL;
        xlator_t                *this  = NULL;

        question = "Resetting uuid changes the uuid of local glusterd. "
                   "Do you want to continue?";

        if (wordcount != 3) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_UUID_RESET];

        this = THIS;
        frame = create_frame (this, this->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict) {
                ret = -1;
                goto out;
        }
        CLI_LOCAL_INIT (local, words, frame, dict);
        answer = cli_cmd_get_confirmation (state, question);

        if (GF_ANSWER_NO == answer) {
                ret = 0;
                goto out;
        }

        //send NULL as argument since no dictionary is sent to glusterd
        if (proc->fn) {
                ret = proc->fn (frame, this, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("uuid reset failed");
        }

        CLI_STACK_DESTROY (frame);

        return ret;
}
开发者ID:lkzhd,项目名称:glusterfs-annotation,代码行数:60,代码来源:cli-cmd-system.c


示例2: malloc

void *layout_new (void)
{
  tp_layout *ret = (tp_layout*) malloc (sizeof(tp_layout));

  ret->k = 1.0;
  ret->K1 = 0.06;
  ret->K2 = 0.024;
  ret->force = 1.0;
  //viewZone = 5.0; calculated by the quality level
  ret->theta = 0.7;
  ret->quality = 0;
  ret->nodesPerCell = 10;
  ret->maxTreeDepth = 100;

  ret->stabilizationLimit = 0.9;

  tp_rect universe = tp_Rect (-100, -100, 200, 200);
  ret->box = box_new (ret->nodesPerCell, ret->maxTreeDepth, universe);

  ret->nodes = dict_new (10000);

  layout_reset_energies (ret);

  layout_set_quality (ret, ret->quality);
  pthread_mutex_init (&mutex, NULL);
  return ret;
}
开发者ID:schnorr,项目名称:viva,代码行数:27,代码来源:layout.c


示例3: dict_new

static dict_t *pkgmk_confs_explode(dict_t * pkgmk_confs, list_t * ports)
{
	unsigned i, j;
	dict_t *exploded;
	char *key, *pkgmk_conf;
	list_t *list;
	port_t *port;

	exploded = dict_new();

	for (i = 0; i < pkgmk_confs->length; i++) {
		key = xstrdup(pkgmk_confs->elements[i]->key);
		pkgmk_conf = xstrdup(pkgmk_confs->elements[i]->value);
		if (!is_file(pkgmk_conf)) {
			warning("pkgmk's conf %s, not found!", pkgmk_conf);
			free(key);
			free(pkgmk_conf);
			continue;
		}
		list = list_query(ports, port_query_by_name, key);
		for (j = 0; j < list->length; j++) {
			port = list->elements[j];
			if (dict_get(exploded, port->name) == NULL)
				dict_add(exploded, port->name,
					 xstrdup(pkgmk_conf));
		}
		list_free(list, NULL);
		free(key);
		free(pkgmk_conf);
	}

	return exploded;
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:33,代码来源:port.c


示例4: make_seq_dict

static dict_t *
make_seq_dict (int argc, char **argv)
{
        char index[] = "4294967296"; // 1<<32
        int i        = 0;
        int ret      = 0;
        dict_t *dict = dict_new ();

        if (!dict)
                return NULL;

        for (i = 0; i < argc; i++) {
                snprintf(index, sizeof(index), "%d", i);
                ret = dict_set_str (dict, index, argv[i]);
                if (ret == -1)
                        break;
        }

        if (ret) {
                dict_destroy (dict);
                dict = NULL;
        }

        return dict;
}
开发者ID:lkzhd,项目名称:glusterfs-annotation,代码行数:25,代码来源:cli-cmd-system.c


示例5: dict_copy

dict* dict_copy(dict *d)
{
    dict *out;
    if (!d)
        return 0;
    out = dict_new(d->n);
#if defined (HASHMAP)
    hash_map_entry *e;
    hash_map_iterator *i = hash_map_front(d->dict);

    while (!hash_map_iterator_at_end(i))
    {
        e = hash_map_iterator_get(i);
        dict_entry_copy(e->k, e->v, out);
        hash_map_iterator_next(i);
    }
    hash_map_iterator_free(i);
    return out;
#elif defined(TSTC)
    tstc_call(d->dict, 0, dict_entry_copy, out);
    return out;
#else
    return 0;
#endif
}
开发者ID:wongm168,项目名称:PegDF,代码行数:25,代码来源:dict.c


示例6: class_method

PmReturn_t
class_method(pPmObj_t pinstance, pPmObj_t pfunc, pPmObj_t *r_pmeth)
{
    PmReturn_t retval = PM_RET_OK;
    uint8_t *pchunk;
    pPmMethod_t pmeth;
    pPmObj_t pattrs;
    uint8_t objid;

    /* Allocate a method */
    retval = heap_getChunk(sizeof(PmMethod_t), &pchunk);
    PM_RETURN_IF_ERROR(retval);
    OBJ_SET_TYPE(pchunk, OBJ_TYPE_MTH);

    /* Set method fields */
    pmeth = (pPmMethod_t)pchunk;
    pmeth->m_instance = (pPmInstance_t)pinstance;
    pmeth->m_func = (pPmFunc_t)pfunc;
    pmeth->m_attrs = C_NULL;

    /* Create the attributes dict */
    heap_gcPushTempRoot((pPmObj_t)pmeth, &objid);
    retval = dict_new(&pattrs);
    heap_gcPopTempRoot(objid);
    pmeth->m_attrs = (pPmDict_t)pattrs;

    *r_pmeth = (pPmObj_t)pmeth;
    return retval;
}
开发者ID:renlexing,项目名称:projects,代码行数:29,代码来源:class.c


示例7: class_instantiate

/* Returns an instance of the class by reference */
PmReturn_t
class_instantiate(pPmObj_t pclass, pPmObj_t *r_pobj)
{
    PmReturn_t retval = PM_RET_OK;
    uint8_t *pchunk;
    pPmObj_t pobj;
    pPmObj_t pattrs;
    uint8_t objid;

    /* Allocate a class instance */
    retval = heap_getChunk(sizeof(PmInstance_t), &pchunk);
    PM_RETURN_IF_ERROR(retval);
    pobj = (pPmObj_t)pchunk;
    OBJ_SET_TYPE(pobj, OBJ_TYPE_CLI);

    /* Set the instance's fields */
    ((pPmInstance_t)pobj)->cli_class = (pPmClass_t)pclass;
    ((pPmInstance_t)pobj)->cli_attrs = C_NULL;

    /* Create the attributes dict */
    heap_gcPushTempRoot(pobj, &objid);
    retval = dict_new(&pattrs);
    heap_gcPopTempRoot(objid);
    ((pPmInstance_t)pobj)->cli_attrs = (pPmDict_t)pattrs;

    /* TODO: Store pclass in __class__ attr */

    *r_pobj = pobj;
    return retval;
}
开发者ID:renlexing,项目名称:projects,代码行数:31,代码来源:class.c


示例8: awlenv_new

awlenv* awlenv_new(void) {
    awlenv* e = safe_malloc(sizeof(awlenv));
    e->parent = NULL;
    e->internal_dict = dict_new(awlval_copy_proxy, awlval_del_proxy);
    e->top_level = false;
    e->references = 1;
    return e;
}
开发者ID:8l,项目名称:awl,代码行数:8,代码来源:types.c


示例9: store_function

static void store_function(const char*name, value_t*value)
{
    ID id = rb_intern(name);
    if(!global->functions) {
        global->functions = dict_new(&ptr_type);
    }
    dict_put(global->functions, (void*)id, value);
}
开发者ID:luiseduardohdbackup,项目名称:cagekeeper,代码行数:8,代码来源:language_rb.c


示例10: awlval_dict

awlval* awlval_dict(void) {
    awlval* v = safe_malloc(sizeof(awlval));
    v->type = AWLVAL_DICT;
    v->count = 0;
    v->length = 0;
    v->d = dict_new(awlval_copy_proxy, awlval_del_proxy);
    return v;
}
开发者ID:8l,项目名称:awl,代码行数:8,代码来源:types.c


示例11: main

int main(){

	struct dictionary *d;
	int i;
	d = dict_new(1,0);
	int min;
	int nums[7];
	int keys[7];
	
	keys[0] = 9;
	nums[0] = 14; 
	
	keys[1] = 4;
	nums[1] = 7; 
	
	keys[2] = 12;
	nums[2] = 5; 
	
	keys[3] = 0;
	nums[3] = 15; 
	
	keys[4] = 2;
	nums[4] = 3; 
	
	keys[5] = 14;
	nums[5] = 4; 
	
	keys[6] = 5;
	nums[6] = 2; 
	
	printf("new\n");
	
	//~ printHash(d);
		
	for(i = 0; i < 7; i++){
		//~ printf("Inserting %d...\n",nums[i]);
		dict_set(d,keys[i],nums[i]);
		//~ printHash(d);
	}
	
	printHash(d);
	
	dict_set(d,2,8);
	printf("set key 2 con 8\n");
	printf("get key 2 = %d\n",dict_get(d,2));
	
	printf("delete key 2\n");
	dict_delete(d,2);
	printHash(d);
	
	printf("delete key 9\n");
	dict_delete(d,9);
	printHash(d);
	
	dict_free(d);


}
开发者ID:vitorohe,项目名称:Tarea3Alg,代码行数:58,代码来源:test_hash.c


示例12: cli_cmd_peer_probe_cbk

int
cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,
                   const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        dict_t                  *dict = NULL;
        int                     sent = 0;
        int                     parse_error = 0;

        if (!(wordcount == 3)) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROBE];

        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict)
                goto out;

        ret = dict_set_str (dict, "hostname", (char *)words[2]);
        if (ret)
                goto out;

        ret = valid_internet_address ((char *) words[2]);
        if (ret == 1) {
                ret = 0;
        } else {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }
/*        if (words[3]) {
                ret = dict_set_str (dict, "port", (char *)words[3]);
                if (ret)
                        goto out;
        }
*/
        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Peer probe failed");
        }
        return ret;
}
开发者ID:BillTheBest,项目名称:glusterfs,代码行数:57,代码来源:cli-cmd-peer.c


示例13: xmalloc

ini_t *ini_new(char *filepath)
{
	ini_t *self;

	self = xmalloc(sizeof(ini_t));
	self->filepath = xstrdup(filepath);
	self->sections = dict_new();
	return self;
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:9,代码来源:ini.c


示例14: qserver_init

int
qserver_init(void)
{
    qserver_log = log_register_type("QServer", "file:qserver.log");
    conf_register_reload(qserver_conf_read);
    qserver_dict = dict_new();
    reg_exit_func(qserver_cleanup, NULL);
    return 1;
}
开发者ID:Cloudxtreme,项目名称:x3,代码行数:9,代码来源:mod-qserver.c


示例15: initialize_parser

void initialize_parser()
{
    global = rfx_calloc(sizeof(global_t));
    global->file = abc_file_new();
    global->file->flags &= ~ABCFILE_LAZY;
    global->file2token2info = dict_new();
    global->token2info = 0;
    global->classinit = abc_initscript(global->file);
}
开发者ID:DJwa163,项目名称:swftools,代码行数:9,代码来源:parser_help.c


示例16: time_mod_init

void time_mod_init() {
    Object time_mod = dict_new();
    reg_mod_func(time_mod, "time",  bf_time_time);
    reg_mod_func(time_mod, "clock", bf_time_clock);
    reg_mod_func(time_mod, "ctime", bf_time_ctime);
    reg_mod_func(time_mod, "sleep", bf_time_sleep);
    reg_mod_func(time_mod, "asctime", bf_time_asctime);
    dict_set_by_str(tm->modules, "time", time_mod);
}
开发者ID:xupingmao,项目名称:minipy,代码行数:9,代码来源:time.c


示例17: cli_cmd_volume_rename_cbk

int
cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word,
                           const char **words, int wordcount)
{
        int                     ret = -1;
        rpc_clnt_procedure_t    *proc = NULL;
        call_frame_t            *frame = NULL;
        dict_t                  *dict = NULL;
        int                     sent = 0;
        int                     parse_error = 0;


        frame = create_frame (THIS, THIS->ctx->pool);
        if (!frame)
                goto out;

        dict = dict_new ();
        if (!dict)
                goto out;

        if (wordcount != 4) {
                cli_usage_out (word->pattern);
                parse_error = 1;
                goto out;
        }

        ret = dict_set_str (dict, "old-volname", (char *)words[2]);

        if (ret)
                goto out;

        ret = dict_set_str (dict, "new-volname", (char *)words[3]);

        if (ret)
                goto out;

        proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RENAME_VOLUME];

        if (proc->fn) {
                ret = proc->fn (frame, THIS, dict);
        }

out:
        if (dict)
                dict_destroy (dict);

        if (ret) {
                cli_cmd_sent_status_get (&sent);
                if ((sent == 0) && (parse_error == 0))
                        cli_out ("Volume rename on '%s' failed", (char *)words[2]);
        }

        return ret;
}
开发者ID:pavantc,项目名称:glusterd_scalability,代码行数:54,代码来源:cli-cmd-volume.c


示例18: os_mod_init

void os_mod_init() {
    Object os_mod = dict_new();
    dict_set_by_str(tm->modules, "os", os_mod);
    reg_mod_func(os_mod, "getcwd",  os_getcwd);
    reg_mod_func(os_mod, "listdir", os_listdir);
    reg_mod_func(os_mod, "chdir",   os_chdir);
    reg_mod_func(os_mod, "stat",    os_stat);
    reg_mod_func(os_mod, "exists",  os_exists);
    
    reg_builtin_func("exists", os_exists);
}
开发者ID:xupingmao,项目名称:minipy,代码行数:11,代码来源:os.c


示例19: dict_new

const char*register_string(const char*s)
{
    if(!stringpool) {
        stringpool = dict_new(&charptr_type);
    }
    char*stored_string = dict_lookup(stringpool, s);
    if(!stored_string) {
        stored_string = (char*)strdup(s);
        dict_put(stringpool, s, stored_string);
    }
    return stored_string;
}
开发者ID:bakineggs,项目名称:mrscake,代码行数:12,代码来源:stringpool.c


示例20: cli_cmd_log_locate_parse

int32_t
cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options)
{
        dict_t  *dict = NULL;
        char    *volname = NULL;
        char    *str = NULL;
        int     ret = -1;
        char    *delimiter = NULL;

        GF_ASSERT (words);
        GF_ASSERT (options);

        GF_ASSERT ((strcmp (words[0], "volume")) == 0);
        GF_ASSERT ((strcmp (words[1], "log")) == 0);
        GF_ASSERT ((strcmp (words[2], "locate")) == 0);

        dict = dict_new ();
        if (!dict)
                goto out;

        volname = (char *)words[3];
        GF_ASSERT (volname);

        ret = dict_set_str (dict, "volname", volname);
        if (ret)
                goto out;

        if (words[4]) {
                delimiter = strchr (words[4], ':');
                if (!delimiter || delimiter == words[4]
                    || *(delimiter+1) != '/') {
                        cli_out ("wrong brick type: %s, use <HOSTNAME>:"
                                 "<export-dir-abs-path>", words[4]);
                        ret = -1;
                        goto out;
                } else {
                        cli_path_strip_trailing_slashes (delimiter + 1);
                }
                str = (char *)words[4];
                ret = dict_set_str (dict, "brick", str);
                if (ret)
                        goto out;
        }

        *options = dict;

out:
        if (ret && dict)
                dict_destroy (dict);

        return ret;
}
开发者ID:mdjunaid,项目名称:glusterfs,代码行数:52,代码来源:cli-cmd-parser.c



注:本文中的dict_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dict_read_first函数代码示例发布时间:2022-05-30
下一篇:
C++ dict_lookup函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap