bool xRedisClient::sdiffstore(const RedisDBIdx& dbi,  const KEY& destinationkey,  const DBIArray& vdbi, const KEYS& vkey, int64_t& count) {
    VALUES sValue;
    if (!sdiff(vdbi, vkey, sValue)) {
        return false;
    }
    return sadd(dbi, destinationkey, sValue, count);
}
Exemple #2
0
VAR* grad(VAR* A) {
  VAR * ret_var = new VAR;
  int type1 = A->get_type();
  if(type1 == 0 || type1 == 2){ ret_var->set_type(-1); }
  else if(type1==1){
  ret_var->set_type(2);
	for(int x = 0; x < DIM_SIZE; x++){
		for(int y = 0; y < DIM_SIZE; y++){
			for(int z = 0; z < DIM_SIZE; z++){
				for(int v = 0; v < 3; v++){
					ret_var->vf[x][y][z][v] = sdiff(A,x,y,z,v);
				}
			}
		}
	}
  }
	delete A; 
  return ret_var;
}
Exemple #3
0
int main(int argc, char **argv)
{
	HC_DEF_S(s);

	s_catz(s, "hello world of possibilities!");
	HC_SAFE_CSTR(s);

	fprintf(stdout, "[%i][%i][%s]\n", s->len, s->a, s->s);

	s->len = 0;  /* truncate string */

	s_catn(s, "hi ", 3);
	fwrite(s->s, s->len, 1, stdout);

	s_copyc(s, 'f');
	s_catz(s, "olk");
	s_catc(s, 's');
	s_catc(s, '!');
	s_catc(s, '\n');
	fwrite(s->s, s->len, 1, stdout);

	s_upper(s);
	fwrite(s->s, s->len, 1, stdout);

	s_lower(s);
	fwrite(s->s, s->len, 1, stdout);

	s_copyz(s, "aa");

	assert(sdiff("aa", "aa") == 0);
	assert(s_diffz(s, "aa") == 0);
	assert(s_diffn(s, "aa", slen("aa")) == 0);

	assert(sdiff("aa", "aaz") < 0);
	assert(s_diffz(s, "aaz") < 0);
	assert(s_diffn(s, "aaz", slen("aaz")) < 0);

	assert(sdiff("aa", "a0z") > 0);
	assert(s_diffz(s, "a0z") > 0);
	assert(s_diffn(s, "a0z", slen("a0z")) > 0);

	assert(sdiff("aa", "0") > 0);
	assert(s_diffz(s, "0") > 0);
	assert(s_diffn(s, "0", slen("0")) > 0);

	assert(sdiff("aa", "0zz") > 0);
	assert(s_diffz(s, "0zz") > 0);
	assert(s_diffn(s, "0zz", slen("0zz")) > 0);

	assert(sdiff("aa", "a") > 0);
	assert(s_diffz(s, "a") > 0);
	assert(s_diffn(s, "a", slen("a")) > 0);

	assert(sdiff("aa", "a0") > 0);
	assert(s_diffz(s, "a0") > 0);
	assert(s_diffn(s, "a0", slen("a0")) > 0);

	s_free(s);

	/*
	 */

	assert(s_cat_u4_hex(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_hex(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_u4_hex(s, 0xffffffff) == 8);
	assert(s_diffz(s, "ffffffff") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_hex(s, (int32_t)0xffffffff) == 2);
	assert(s_diffz(s, "-1") == 0);
	print_s("[", s, "]\n");

	s_free(s);

	/*
	 */

	assert(s_cat_u4_dec(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_dec(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_u4_dec(s, 0xffffffff) == 10);
	assert(s_diffz(s, "4294967295") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_dec(s, (int32_t)0xffffffff) == 2);
	assert(s_diffz(s, "-1") == 0);
	print_s("[", s, "]\n");

	s_free(s);

	/*
	 */

	assert(s_cat_u4_base36(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_base36(s, 0) == 1);
	assert(s_diffz(s, "0") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_u4_base36(s, 0xffffffff) == 7);
	assert(s_diffz(s, "1z141z3") == 0);
	print_s("[", s, "]\n");

	s->len = 0;
	assert(s_cat_i4_base36(s, (int32_t)0xffffffff) == 2);
	assert(s_diffz(s, "-1") == 0);
	print_s("[", s, "]\n");

	s_free(s);

	/*
	 */

	{
		void *out;
		int putlen;
		HC_DEF_S(t);

		s_copyz(s, "hello world of possibilities!");
		putlen = s_putlen(s);

		HC_ALLOC(out, putlen);

		assert(s_put(s, out) == putlen);
		assert(s_get(t, out) == putlen);
		assert(s_diff(s, t) == 0);

		s->len = 0;
		s_reprn(s, out, putlen);
		print_s("[", s, "]\n");

		HC_FREE(out);
		s_free(t);
	}

	/*
	 */

	s_free(s);

	return 0;
}