/* * exchange two vm_val_t elements */ void CVmQSortVal::exchange(VMG_ size_t a, size_t b) { vm_val_t val_a; vm_val_t val_b; /* get the two elements */ get_ele(vmg_ a, &val_a); get_ele(vmg_ b, &val_b); /* store the two elements, swapping the positions */ set_ele(vmg_ b, &val_a); set_ele(vmg_ a, &val_b); }
/* * compare two vm_val_t values */ int CVmQSortVal::compare(VMG_ size_t a, size_t b) { int result; vm_val_t val_a; vm_val_t val_b; /* get the two values */ get_ele(vmg_ a, &val_a); get_ele(vmg_ b, &val_b); /* check for an explicit comparison function */ if (compare_fn_.typ != VM_NIL) { vm_val_t val; /* push the values (in reverse order) */ G_stk->push(&val_b); G_stk->push(&val_a); /* invoke the callback */ G_interpreter->call_func_ptr(vmg_ &compare_fn_, 2, &rc, 0); /* get the result */ val = *G_interpreter->get_r0(); /* if it's not an integer, it's a problem */ if (val.typ != VM_INT) err_throw(VMERR_INT_VAL_REQD); /* get the result value */ result = val.val.intval; } else { /* compare the values */ result = val_a.compare_to(vmg_ &val_b); } /* if we're sorting in descending order, reverse the result */ if (descending_) result = -result; /* return the result */ return result; }
char *prev(t_dlist *list) { char *tmp3; char *tmp4; if (ft_search_list(list, "OLDPWD=") != 0 && ft_strlen(get_ele(list, ft_search_list(list, "OLDPWD="))) > 7) return (get_ele(list, ft_search_list(list, "OLDPWD=")) + 7); else { if (ft_search_list(list, "OLDPWD=") != 0) ft_del_ele_list(list, ft_search_list(list, "OLDPWD="), list->p_head, 1); tmp4 = getcwd(0, 0); tmp3 = ft_strjoin("OLDPWD=", tmp4); free(tmp4); ins_avant(list, tmp3, list->p_head, 0); free(tmp3); return (NULL); } }
void printVec(const Teuchos::RCP<const Thyra::VectorBase<Scalar> > &vec) const { std::cout << "GAH Vector is: " << std::endl; for(int ii=0; ii < vec->space()->dim(); ii++) std::cout << get_ele(*vec, ii) << std::endl; }