/* the main program... */ int main(int UNUSED(argc),char UNUSED(*argv[])) { SET *set; const char **list; int i; /* initialize */ set=set_new(); /* store some entries */ set_add(set,"key1"); set_add(set,"key2"); set_add(set,"key3"); set_add(set,"key2"); /* check set contents */ assert(set_contains(set,"key1")); assert(set_contains(set,"key2")); assert(set_contains(set,"key3")); assert(!set_contains(set,"key4")); assert(!set_contains(set,"KEY1")); /* loop over set contents */ list=set_tolist(set); for (i=0;list[i]!=NULL;i++) { assert(isknownvalue(list[i])); } /* remove keys from the set */ assert(isknownvalue(set_pop(set))); assert(isknownvalue(set_pop(set))); assert(isknownvalue(set_pop(set))); assert(set_pop(set)==NULL); /* free set */ set_free(set); free(list); return 0; }
void RseLogin::MergeFrom(const RseLogin& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_currenttimemillis(from.currenttimemillis()); } if (from._has_bit(1)) { set_id(from.id()); } if (from._has_bit(2)) { set_levelbasedonscore(from.levelbasedonscore()); } if (from._has_bit(3)) { set_myaccountislocked(from.myaccountislocked()); } if (from._has_bit(4)) { set_pop(from.pop()); } if (from._has_bit(5)) { set_rqid(from.rqid()); } if (from._has_bit(6)) { set_sync(from.sync()); } if (from._has_bit(7)) { set_timefromlastlogin(from.timefromlastlogin()); } } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from._has_bit(8)) { set_timefromlastupdate(from.timefromlastupdate()); } if (from._has_bit(9)) { set_token(from.token()); } if (from._has_bit(10)) { set_userid(from.userid()); } if (from._has_bit(11)) { set_version(from.version()); } if (from._has_bit(12)) { set_vip(from.vip()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
static AstarArray* search(AstarNode *current, int dst, Set *open_set, Set *close_set, void *ud) { AstarArray *adjs = NULL; if (!current) return NULL; adjs = get_adjs(ud, current->index); int j; for (j = 0; j < adjs->len; j++) { int i = adjs->arr[j]; if (i == dst) { return path_backtrace(current, dst); } if (set_find(close_set, i) != -1) continue; int new_g = gscore(ud, current->index, i) + current->g; int index; if ((index = set_find(open_set, i)) != -1) { AstarNode *node = set_index(open_set, index); if (node->g < new_g) { continue; } node->g = new_g; node->parent = current; set_bubble(open_set, index); } else { AstarNode *node = create_node(ud, i, dst, current); set_insert(open_set, node); } } array_release(&adjs); int x = current->index % 30; int y = current->index / 30; printf("current is %d %d\n",x,y ); fflush(stdout); set_push(close_set, current); AstarNode *next = set_pop(open_set); return search(next, dst, open_set, close_set, ud); }