int main(int argc, char **argv) { srand (16); int i; for(i = 0; i < 16; ++i) { int a = rand(); int b = rand(); printf("%x > %x -> result:%d\n", a, b, op_ne(a, b)); } return 0; }
void PPNEQGeneralComparison::do_next (xqp_tuple &t) { if (first_time) { first_time = false; if (!eos_reached1) seq1.op->reopen(); if (!eos_reached2) seq2.op->reopen(); eos_reached2 = false; eos_reached1 = false; xqp_tuple cont1(seq1.ts); xqp_tuple cont2(seq2.ts); xqp_tuple * cont[2]={&cont1,&cont2}; PPOpIn * seq[2]={&seq1,&seq2}; bool seq_end[2]={false,false}; bool two_diffs_exist[2]={false,false}; bool uv_exist[2]={false,false}; bool switcher=true; tuple_cell seq_str_val[2]; seq[0]->op->next(*cont[0]); if ((*cont[0]).is_eos()) { eos_reached1 = true; t.copy(tuple_cell::atomic(false)); return; } seq[1]->op->next(*cont[1]); if ((*cont[1]).is_eos()) { eos_reached2 = true; t.copy(tuple_cell::atomic(false)); return; } tuple_cell res[2]; res[0]=getAtomizedCell(*cont[0]); if (res[0].get_atomic_type()==xs_untypedAtomic) { seq_str_val[0]=res[0]; uv_exist[0]=true; } res[1]=getAtomizedCell(*cont[1]); if (res[1].get_atomic_type()==xs_untypedAtomic) { seq_str_val[1]=res[1]; uv_exist[1]=true; } generalNodePrepare(res[0],res[1]); if (op_ne(res[0],res[1],handler).get_xs_boolean()) { t.copy(tuple_cell::atomic(true)); return; } int pr=0; while(true) { (switcher)?pr=0:pr=1; switcher=!switcher; if (!seq_end[pr] ) { seq[pr]->op->next(*cont[pr]); if (cont[pr]->is_eos()) { (pr==0)? eos_reached1 = true: eos_reached2 = true; seq_end[pr]=true; if (seq_end[1-pr]) { t.copy(tuple_cell::atomic(false)); return; } } else { res[pr]=getAtomizedCell(*cont[pr]); if (res[pr].get_atomic_type()==xs_untypedAtomic) { if (!uv_exist[pr]) { seq_str_val[pr]=res[pr]; uv_exist[pr]=true; } else { if (op_ne(cast(seq_str_val[pr], xs_string),cast(res[pr], xs_string),handler).get_xs_boolean()) two_diffs_exist[pr]=true; } if ( (two_diffs_exist[pr]&& uv_exist[1-pr])|| (two_diffs_exist[1-pr]&& uv_exist[pr]) ) { t.copy(tuple_cell::atomic(true)); return; } if (uv_exist[1-pr]) { if (op_ne(cast(seq_str_val[pr], xs_string),cast(seq_str_val[1-pr], xs_string),handler).get_xs_boolean()) { t.copy(tuple_cell::atomic(true)); return; } } } generalNodePrepare(res[0],res[1]); if (op_ne(res[0],res[1],handler).get_xs_boolean()) { t.copy(tuple_cell::atomic(true)); return; } } } } } else { first_time = true; t.set_eos(); } }