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

C++ set_add函数代码示例

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

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



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

示例1: while

// Performs a union of two sets, does not allow duplicate values
struct set_t *set_union(struct set_t *set1, struct set_t *set2) {

    struct set_t *temp_set_head = NULL;
    struct set_t *temp_set_it = NULL;
    struct set_t *set_it = set1;

    // Add each element of set1
    while(set_it != NULL) {
        if(temp_set_head == NULL) {
            temp_set_head = new_set(set_it->value);
            temp_set_it = temp_set_head;
        } else {
            temp_set_it->next = set_add(temp_set_head, set_it->value);
            if(temp_set_it->next != NULL)
                temp_set_it = temp_set_it->next;
        }
        set_it = set_it->next;
    }

    // Add each element of set2
    set_it = set2;
    while(set_it != NULL) {
        if(temp_set_head == NULL) {
            temp_set_head = new_set(set_it->value);
            temp_set_it = temp_set_head;
        } else {
            temp_set_it->next = set_add(temp_set_head, set_it->value);
            if(temp_set_it->next != NULL)
                temp_set_it = temp_set_it->next;
        }
        set_it = set_it->next;
    }

    return temp_set_head;
}
开发者ID:storyeah,项目名称:jkcompiler,代码行数:36,代码来源:set.c


示例2: main

int
main(int argc, char **argv)
{
	struct set *set;
	const char *str1 = "test1";
	const char *str2 = "test2";
	const char *str3 = "test3";

	set = set_create(badhash, string_key_equals);

	/* Unlike the hash table equivalent of this test, use an extra
	 * string so that the rehash happens at the right time.
	 */
	set_add(set, str1);
	set_add(set, str2);
	set_add(set, str3);
	set_remove(set, str2);
	set_add(set, str3);
	set_remove(set, str3);
	assert(!set_contains(set, str3));

	set_destroy(set, NULL);

	return 0;
}
开发者ID:anholt,项目名称:hash_table,代码行数:25,代码来源:collision_replacement.c


示例3: steam_init

/**
 * Implements #prpl->init(). This initializes the an account.
 *
 * @param acc The #account_t.
 **/
static void steam_init(account_t *acc)
{
    set_t *s;

    s = set_add(&acc->set, "authcode", NULL, steam_eval_accounton, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_NOSAVE;

    s = set_add(&acc->set, "captcha", NULL, steam_eval_accounton, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_NOSAVE;

    s = set_add(&acc->set, "esid", NULL, NULL, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_NOSAVE;

    s = set_add(&acc->set, "cgid", NULL, NULL, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_NOSAVE;

    s = set_add(&acc->set, "umqid", NULL, NULL, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN;

    s = set_add(&acc->set, "token", NULL, NULL, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_PASSWORD;

    s = set_add(&acc->set, "sessid", NULL, NULL, acc);
    s->flags = SET_NULL_OK | SET_HIDDEN | SET_PASSWORD;

    s = set_add(&acc->set, "show_playing", "%", steam_eval_show_playing, acc);
    s->flags = SET_NULL_OK;

    set_add(&acc->set, "game_status", "false", steam_eval_game_status, acc);
    set_add(&acc->set, "password", NULL, steam_eval_password, acc);
}
开发者ID:dequis,项目名称:bitlbee-steam,代码行数:36,代码来源:steam.c


示例4: main

int main(int argc,
         char *argv[]) {
  void *a = new(String, "a");
  void *b = new(String, "bbb");
  void *s = new(Set);

  printf("LENGTH A: %lu\n", string_length(a));
  printf("LENGTH B: %lu\n", string_length(b));

  printf("Prev: %s\n", string_get(a));
  string_set(a, "New String");
  printf("New:  %s\n", string_get(a));

  set_add(s, a);
  set_add(s, b);

  printf("CONTAINS A: %u\n", set_contains(s, a));
  printf("CONTAINS B: %u\n", set_contains(s, b));

  printf("DROP B: %p\n", set_drop(s, b));
  printf("DROP B: %p\n", set_drop(s, b));

  printf("ADD B: %p\n", set_add(s, b));

  delete(s);
  delete(a);
  delete(b);

  return 0;
}
开发者ID:BinaryTENSHi,项目名称:c_stuffs,代码行数:30,代码来源:main.c


示例5: g_new0

irc_channel_t *irc_channel_new(irc_t *irc, const char *name)
{
	irc_channel_t *ic;
	set_t *s;

	if (!irc_channel_name_ok(name) || irc_channel_by_name(irc, name)) {
		return NULL;
	}

	ic = g_new0(irc_channel_t, 1);
	ic->irc = irc;
	ic->name = g_strdup(name);
	strcpy(ic->mode, CMODE);

	irc_channel_add_user(ic, irc->root);

	irc->channels = g_slist_append(irc->channels, ic);

	set_add(&ic->set, "auto_join", "false", set_eval_bool, ic);

	s = set_add(&ic->set, "type", "control", set_eval_channel_type, ic);
	s->flags |= SET_NOSAVE;    /* Layer violation (XML format detail) */

	if (name[0] == '&') {
		set_setstr(&ic->set, "type", "control");
	} else { /* if( name[0] == '#' ) */
		set_setstr(&ic->set, "type", "chat");
	}

	return ic;
}
开发者ID:andrewalker,项目名称:bitlbee,代码行数:31,代码来源:irc_channel.c


示例6: insert_loop_node

static void
insert_loop_node (flowloop_t *loop, unsigned n, set_t *stack)
{
	if (!set_is_member (loop->nodes, n)) {
		set_add (loop->nodes, n);
		set_add (stack, n);
	}
}
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:8,代码来源:flow.c


示例7: main

int main(void) 
{
  set s1, s2;
  int m = 10;

  s1 = set_init(m);
  set_add(s1, 1);
  set_add(s1, 3);
  set_add(s1, 5);
  s2 = set_init(m + 2);
  set_add(s2, 0);
  set_add(s2, 2);
  set_add(s2, 3);
  set_add(s2, 4);
  set_add(s2, 5);
  set_add(s2, 11);
  set_print(s1);
  printf("\n");
  set_print(s2);
  printf("\nIntersection: ");
  set_print(set_intersection(s1, s2));
  printf("\nUnion: ");
  set_print(set_union(s1, s2));
  printf("\nComplement for s2: ");
  set_print(set_complement(s2));
  printf("\n");  
  return 0;
}
开发者ID:KnightSch,项目名称:Sedgewick-algorithms-in-c-exercises-and-examples,代码行数:28,代码来源:main.c


示例8: __hamt_new_node

static struct hamt_node *__hamt_new_node2(struct hamt_root *root,
					  void *item1, int slice1,
					  void *item2, int slice2)
{
	struct hamt_node *node =                \
		__hamt_new_node(root,
				set_add(set_add(0ULL, slice1), slice2),
				2);
	node->slots[set_slot_number(node->mask, slice1)] = item_to_slot(item1);
	node->slots[set_slot_number(node->mask, slice2)] = item_to_slot(item2);
	return node;
}
开发者ID:4n3w,项目名称:dump,代码行数:12,代码来源:hamt.c


示例9: msn_init

static void msn_init( account_t *acc )
{
	set_t *s;
	
	s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
	s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
	
	set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
	set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
	
	acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE |
	              ACC_FLAG_HANDLE_DOMAINS;
}
开发者ID:GRMrGecko,项目名称:bitlbee,代码行数:13,代码来源:msn.c


示例10: set_test

void
set_test()
{
	printf("SET S: ");
	set* s = set_init();
	set_add(s, (SETDATA*)1);
	set_add(s, (SETDATA*)2);
	set_add(s, (SETDATA*)3);
	set_add(s, (SETDATA*)4);
	set_add(s, (SETDATA*)5);
	set_add(s, (SETDATA*)6);
	set_print(s, set_testcb);

	printf("S \\ 2, 6: ");
	set_remove(s, (SETDATA*)6);
	set_remove(s, (SETDATA*)2);
	set_print(s, set_testcb);
	
	printf("SET T: ");
	set* t = set_init();
	set_add(t, (SETDATA*)1);
	set_add(t, (SETDATA*)2);
	set_add(t, (SETDATA*)9);
	set_add(t, (SETDATA*)4);
	set_print(t, set_testcb);
	
	printf("UNION OF S, T: ");
	set* u = set_init();
	set_union(u, s, t);
	set_print(u, set_testcb);
	
	printf("INTERSECTION OF S, T: ");
	set* i = set_init();
	set_intersection(i, s, t);
	set_print(i, set_testcb);
	
	printf("DIFFERENCE OF S, T: ");
	set* d = set_init();
	set_difference(d, s, t);
	set_print(d, set_testcb);
	
	printf("CLEAR S: ");
	set_clear(s);
	set_print(s, set_testcb);
	
	set_free(s);
	set_free(t);
	set_free(u);
	set_free(i);
	set_free(d);
}
开发者ID:Zugamifk,项目名称:fishermans,代码行数:51,代码来源:set.c


示例11: range_from_braces

range* range_from_braces(range_request* rr,
                         const range* r1, const range* r2, const range* r3)
{
    int i, j, k;
    set_element** m1;
    set_element** m2;
    set_element** m3;
    set* temp = NULL;
    range* bigrange;
    char* bundle;
    apr_pool_t* pool = range_request_pool(rr);
    
    if(r1->nodes->members == 0) {
        if(!temp) {
            temp = set_new(pool, 1);
            set_add(temp, "", NULL);
        }
        m1 = set_members(temp);
    } else m1 = set_members(r1->nodes);

    if(r2->nodes->members == 0) {
        if(!temp) {
            temp = set_new(pool, 1);
            set_add(temp, "", NULL);
        }
        m2 = set_members(temp);
    } else m2 = set_members(r2->nodes);

    if(r3->nodes->members == 0) {
        if(!temp) {
            temp = set_new(pool, 1);
            set_add(temp, "", NULL);
        }
        m3 = set_members(temp);
    } else m3 = set_members(r3->nodes);

    bigrange = range_new(rr);

    for(i = 0; m1[i]; i++)
        for(j = 0; m2[j]; j++)
            for(k = 0; m3[k]; k++) {
                bundle = apr_pstrcat(pool,
                                    m1[i]->name, m2[j]->name,
                                     m3[k]->name, NULL);
                range_add(bigrange, bundle);
            }

    if (temp) set_destroy(temp);
    bigrange->quoted = r1->quoted || r2->quoted || r3->quoted;
    return bigrange;
}
开发者ID:anthonybishopric,项目名称:libcrange,代码行数:51,代码来源:range.c


示例12: set_add

void set_add(set_t** set, void* object)
{
	assert(set != NULL);
	if (*set == NULL) {
		*set = malloc(sizeof(set_t));
		(*set)->data = object;
		(*set)->left = NULL;
		(*set)->right = NULL;
	} else if ((*set)->data > object) {
		set_add(&(*set)->left, object);
	} else if ((*set)->data < object) {
		set_add(&(*set)->right, object);
	}
}
开发者ID:bitzhuwei,项目名称:Polyspasm,代码行数:14,代码来源:treeset.c


示例13: main

int main()
{
    std::vector<int> set({10});
    set_add(set, 16);
    set_add(set, 16);
    set_add(set, 10);
    set_add(set, 5);
    set_add(set, 5);

    print(set.begin(), set.end());

    std::cout << count_of_equals(set.begin(), set.end(), 16) << std::endl;

    return 0;
}
开发者ID:adkozlov,项目名称:cpp-2014,代码行数:15,代码来源:main.cpp


示例14: set_intersect_int

STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
    if (update) {
        check_set(self_in);
    } else {
        check_set_or_frozenset(self_in);
    }

    if (self_in == other) {
        return update ? mp_const_none : set_copy(self_in);
    }

    mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
    mp_obj_set_t *out = MP_OBJ_TO_PTR(mp_obj_new_set(0, NULL));

    mp_obj_t iter = mp_getiter(other, NULL);
    mp_obj_t next;
    while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
        if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) {
            set_add(MP_OBJ_FROM_PTR(out), next);
        }
    }

    if (update) {
        m_del(mp_obj_t, self->set.table, self->set.alloc);
        self->set.alloc = out->set.alloc;
        self->set.used = out->set.used;
        self->set.table = out->set.table;
    }

    return update ? mp_const_none : MP_OBJ_FROM_PTR(out);
}
开发者ID:Syainn,项目名称:micropython,代码行数:31,代码来源:objset.c


示例15: ro2sslose

int 
ro2sslose (struct assocblk *acb, int result)
{
	int     len;
	char   *base;
	PE	    pe;
	struct SSAPindication   sis;

	base = NULL, len = 0;
	/* begin AbortInformation PSDU (pseudo) */
	if (pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET)) {
		if (set_add (pe, num2prim ((integer) result, PE_CLASS_CONT, 0))
				!= NOTOK)
			 pe2ssdu (pe, &base, &len);

		PLOGP (rosap_log,OACS_AbortInformation, pe, "AbortInformation",
			   0);

		pe_free (pe);
	}
	/* end AbortInformation PSDU */

	 SUAbortRequest (acb -> acb_fd, base, len, &sis);
	acb -> acb_fd = NOTOK;

	if (base)
		free (base);
}
开发者ID:Kampbell,项目名称:isode-8.0,代码行数:28,代码来源:ro2ss.c


示例16: switch

_lang_token*
_langspec_translatetoken
(
	_langspec_token* token,
	set* keywordset,
	errorlog* log
)
{
	switch (token->type) {
		case LANGSPEC_TERMINAL: {
			char* str = token->value;
			if (strcmp(str, "#") == 0) {
				return _lang_inittoken(LANG_NUMBER, str);
			} else
			if (strcmp(str, "@") == 0) {
				return _lang_inittoken(LANG_STRING, str);
			} else
			if (strcmp(str, "%") == 0) {
				return _lang_inittoken(LANG_IDENTIFIER, str);
			} else
			{
				set_add(keywordset, str);
				return _lang_inittoken(LANG_KEYWORD, str);
			}
		} break;
		case LANGSPEC_NONTERMINAL: {
			return _lang_inittoken(LANG_NONTERMINAL, token->value);
		}	break;
		default:
			_langspec_generator_error(log, "Expected TERMINAL or NONTERMINAL, got %s", _langspec_tokentypestrings[token->type]);
			return NULL;
	}
}
开发者ID:Zugamifk,项目名称:fishermans,代码行数:33,代码来源:langspec_builder.c


示例17: set_intersect_int

STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
    assert(MP_OBJ_IS_TYPE(self_in, &mp_type_set));
    if (self_in == other) {
        return update ? mp_const_none : set_copy(self_in);
    }

    mp_obj_set_t *self = self_in;
    mp_obj_set_t *out = mp_obj_new_set(0, NULL);

    mp_obj_t iter = mp_getiter(other);
    mp_obj_t next;
    while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
        if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) {
            set_add(out, next);
        }
    }

    if (update) {
        m_del(mp_obj_t, self->set.table, self->set.alloc);
        self->set.alloc = out->set.alloc;
        self->set.used = out->set.used;
        self->set.table = out->set.table;
    }

    return update ? mp_const_none : out;
}
开发者ID:patrickhpunkt,项目名称:micropython,代码行数:26,代码来源:objset.c


示例18: add_depend

static void add_depend(const char *source, set_t *incl, map_t *deps)
{
    set_t *mydeps;
    llnode_t *tmp;
    int i,num;

    if (source == NULL) return;

    mydeps = map_find(deps,source);
    if (mydeps != NULL) {
        num = mydeps->nbuckets;

        for (i = 0; i < num; ++i) {
            tmp = mydeps->buckets + i;
            while (tmp->next != NULL) {
                if (set_find(incl,tmp->key) == 0) {
                    set_add(incl,tmp->key);
                    add_depend(tmp->key,incl,deps);
                }
                tmp = tmp->next;
            }
        }
    }

}
开发者ID:TempleHPC,项目名称:maui-scheduler,代码行数:25,代码来源:fastdep.c


示例19: map_add

/* add an entry to the map */
static void map_add(map_t *m, const char *key, const char *val)
{
    mapnode_t *tmp;
    unsigned int idx;

    if (!m) return;

    idx = hash_func(key) % m->nbuckets;
    tmp = m->buckets + idx;
    while (tmp->next != NULL) {
        if (strcmp(tmp->key,key) == 0) break;
        tmp = tmp->next;
    }

    /* add new entry to map */
    if (tmp->next == NULL) {
        m->count ++;
        tmp->key = my_strdup(key);
        tmp->val = set_init(50); /* XXX: chosen arbitrarily */
        tmp->next = (mapnode_t *)malloc(sizeof(mapnode_t));
        tmp->next->key = NULL;
        tmp->next->val = NULL;
        tmp->next->next = NULL;
    }
    set_add(tmp->val,val);
}
开发者ID:TempleHPC,项目名称:maui-scheduler,代码行数:27,代码来源:fastdep.c


示例20: add_acls

int
add_acls(char *acl, set *s, struct hashtable *aclshash)
{
	char **acls;
	int a, i;

	if (split(acl, ",", &acls) == -1)
		return 0;
	for (i = 0; acls[i] != NULL; i++) {
		char *entry;
		if (strcmp(acls[i], "") == 0) {
			free(acls[i]);
			continue;
		}
		if ((entry = hashtable_search(aclshash, acls[i])) == NULL) {
			entry = acls[i];
			hashtable_insert(aclshash, acls[i], acls[i]);
		} else {
			free(acls[i]);
		}
		if (set_add(s, entry) == 2)
			;
	}
	free(acls);

	return 1;
}
开发者ID:Web5design,项目名称:enterprise-search,代码行数:27,代码来源:acl.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ set_address函数代码示例发布时间:2022-05-30
下一篇:
C++ set_active_framebuffer函数代码示例发布时间: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