void ISelector:: elems_to_be_merged(Grid* grid, TElem* target, TElem* elem1, TElem* elem2) { // if at least one was selected, we'll select the new one too. if(is_selected(elem1) || is_selected(elem2)) select(target); }
PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL void KlassInfoHisto::print_title(outputStream* st, bool csv_format, bool selected[], int width_table[], const char *name_table[]) { if (csv_format) { st->print("Index,Super"); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print(",%s", name_table[c]);} } st->print(",ClassName"); } else { st->print("Index Super"); for (int c=0; c<KlassSizeStats::_num_columns; c++) { PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL if (selected[c]) {st->print(str_fmt(width_table[c]), name_table[c]);} PRAGMA_DIAG_POP } st->print(" ClassName"); } if (is_selected("ClassLoader")) { st->print(",ClassLoader"); } st->cr(); }
void radioItem::get_label(char *buffer) { buffer[0] = ' '; if(is_selected()) { buffer[0] = '*'; } menuItem::get_label(buffer + 1) ; }
int real_db_enumerate_items(struct db_enumerator e) { int item = max(0, e.item + 1); int i; switch(e.mode) { #ifdef DEBUG case ENUM_ALL: break; #endif case ENUM_SELECTED: for(i = item; i <= LAST_ITEM; i++) { if(is_selected(i)) { item = i; goto out; } } return -1; #ifdef DEBUG default: fprintf(stderr, "real_db_enumerate_items() " "BUG: unknown db_enumerator mode: %d\n", e.mode); break; #endif } out: return (item > LAST_ITEM || item < 0) ? -1 : item; }
nc_color inventory_column::get_entry_color( const inventory_entry &entry ) const { if( entry.is_item() ) { return ( active && is_selected( entry ) ) ? h_white : entry.it->color_in_inventory(); } else { return c_magenta; } }
void slide_groups(int x, int y, int selection) { type_groupe *gpe; selected_group *sel_group = NULL; type_liaison * liaison; int selected_planes[nb_max_planes]; int planes_to_select = 0; memset(selected_planes, 0, sizeof(selected_planes)); if (selection == 0) { gpe = sc->deb_groupe; while (gpe != NULL) { gpe->posx += x; gpe->posy += y; gpe = gpe->s; } } else { for (sel_group = sc->groupes_courants; sel_group != NULL; sel_group = sel_group->next) { sel_group->group->posx += x; sel_group->group->posy += y; if (abs(sel_group->group->reverse) >= 100) { planes_to_select = 1; selected_planes[abs(sel_group->group->reverse)] = 1; } } if (planes_to_select == 1) { gpe = sc->deb_groupe; while (gpe != NULL) { if (is_selected(gpe) == NULL && selected_planes[abs(gpe->reverse)] == 1) { gpe->posx += x; gpe->posy += y; } gpe = gpe->s; } } } liaison = sc->deb_liaison; while (liaison != NULL) { if ((liaison->depart != -1) && (liaison->arrivee != -1) ) rescale_link(liaison); liaison = liaison->s; } }
void Tab::Select() { if(!is_selected()) { J2[28] = !J2[28]; InvertPieceOfArray(this->ti.x0+1 , this->ti.y0+1, this->ti.width-2, this->ti.height-2, this->tbuf.prv_slct_buffer, this->tbuf.invert_buffer); set_select(true); } else return; }
void Tab::UnSelect() { if(is_selected()) { J2[32] = !J2[32]; ReturnPieceOfArray(this->ti.x0+1 , this->ti.y0+1, this->ti.width-2, this->ti.height-2, this->tbuf.prv_slct_buffer); set_select(false); } else return; }
twidget* tindependent::find(const std::string& id, const bool must_be_active) { for(size_t i = 0; i < get_item_count(); ++i) { if(is_selected(i)) { if(twidget* widget = item(i).find(id, must_be_active)) { return widget; } } } return NULL; }
nc_color selection_column::get_entry_color( const inventory_entry &entry ) const { if( !entry.is_item() || is_selected( entry ) ) { return inventory_column::get_entry_color( entry ); } else if( entry.item_pos == -1 ) { return c_ltblue; } else if( entry.item_pos <= -2 ) { return c_cyan; } return entry.it->color_in_inventory(); }
nc_color inventory_column::get_entry_color( const inventory_entry &entry ) const { if( entry.is_item() ) { return ( active && is_selected( entry ) ) ? h_white : ( custom_colors && entry.custom_color != c_unset ) ? entry.custom_color : entry.get_item().color_in_inventory(); } else { return c_magenta; } }
std::vector<inventory_entry *> inventory_column::get_all_selected() const { std::vector<inventory_entry *> res; if( allows_selecting() ) { for( const auto &entry : entries ) { if( is_selected( entry ) ) { res.push_back( const_cast<inventory_entry *>( &entry ) ); } } } return res; }
/* * Print debugging info about all the SELECTED * messages and the sequences they are in. * Due limitattions of snprintb(), only a limited * number of sequences will be printed. See the * comments in sbr/seq_bits.c. */ static void seq_printdebug (struct msgs *mp) { int msgnum; char buf[BUFSIZ]; printf ("\n"); for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected (mp, msgnum)) printf ("%*d: %s\n", DMAXFOLDER, msgnum, snprintb (buf, sizeof buf, (unsigned) *bvector_bits (msgstat (mp, msgnum)), seq_bits (mp))); } }
static void copy_mime_draft (int out) { int msgnum; char buffer[BUFSIZ]; snprintf (buffer, sizeof(buffer), "#forw [forwarded message%s] +%s", mp->numsel == 1 ? "" : "s", mp->foldpath); write (out, buffer, strlen (buffer)); for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) if (is_selected (mp, msgnum)) { snprintf (buffer, sizeof(buffer), " %s", m_name (msgnum)); write (out, buffer, strlen (buffer)); } write (out, "\n", 1); }
type_groupe *selection_groupe() { type_groupe *group = NULL; selected_group *sel_group = NULL; if ((group = test_group_position(sc->point_courant_leto)) != NULL) { if ((sel_group = is_selected(group)) == NULL) { selection_select_group(group); } else { selection_unselect_group(sel_group); } return group; } return NULL; }
inline bool is_selected(Iter i, Iter j, const typename mesh::mesh_traits<Mesh>::bucket_key& bucket, Functor has_part, const Mesh& m) { bool result = i != j; while( result && i != j ) { if ( i->m_count ) { // Compound statement result = i->m_unary ^ is_selected(i+1, i+i->m_count, bucket, has_part, m); i += i->m_count; } else { // Test for containment of bucket in this part result = i->m_unary ^ has_part(bucket, i->m_part_id, m); ++i; } } return result; }
void update_selection_rectangle(int xmin, int ymin, int xmax, int ymax, int ctrl_mask) { type_groupe *groupe; selected_group *sel_group, *prev_sel_group; int x, y; if (ctrl_mask == 0) { sel_group = sc->groupes_courants; while (sel_group != NULL) { prev_sel_group = sel_group; sel_group = sel_group->next; x = prev_sel_group->group->posx; y = prev_sel_group->group->posy; if (x < xmin || x > xmax || y < ymin || y > ymax) { selection_unselect_group(prev_sel_group); } } } groupe = sc->deb_groupe; while (groupe != NULL) { x = groupe->posx; y = groupe->posy; if (x >= xmin && x <= xmax && y >= ymin && y <= ymax) { if (is_selected(groupe) == NULL) { selection_select_group(groupe); } } groupe = groupe->s; } }
void KlassInfoHisto::print_title(outputStream* st, bool csv_format, bool selected[], int width_table[], const char *name_table[]) { if (csv_format) { st->print("Index,Super"); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print(",%s", name_table[c]);} } st->print(",ClassName"); } else { st->print("Index Super"); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print(str_fmt(width_table[c]), name_table[c]);} } st->print(" ClassName"); } if (is_selected("ClassLoader")) { st->print(",ClassLoader"); } st->cr(); }
type_groupe * gere_groupe(TxPoint point) { type_groupe *group = NULL; selected_group *sel_group = NULL; int x_center = 0, y_center = 0, nb_selected_groups = 0; if ((group = test_group_position(sc->point_courant_leto)) != NULL) { if (is_selected(group) == NULL) { select_group(group); } if (sc->flag_create_link == LINK_CREATE_NO_ACTION) { sc->flag_drag_group = 1; for (sel_group = sc->groupes_courants; sel_group != NULL; sel_group = sel_group->next) { x_center += sel_group->group->posx; y_center += sel_group->group->posy; nb_selected_groups++; } sc->pointer_selection_center.x = point.x - x_center / nb_selected_groups; sc->pointer_selection_center.y = point.y - y_center / nb_selected_groups; } return group; } else { reset_selection_groups(); sc->flag_drag_group = 0; return NULL; } }
bool has_played( const T &anim ) const { return has_animation_played() && is_selected( anim ); }
int main (int argc, char **argv) { int msgnum, *icachesw; char *cp, *file = NULL, *outfile = NULL, *folder = NULL; char *maildir, buf[100], **argp; char **arguments; struct msgs_array msgs = { 0, 0, NULL }; struct msgs *mp = NULL; CT ct, *ctp; FILE *fp; if (nmh_init(argv[0], 1)) { return 1; } done=freects_done; arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; /* * Parse arguments */ while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { case AMBIGSW: ambigsw (cp, switches); done (1); case UNKWNSW: adios (NULL, "-%s unknown", cp); case HELPSW: snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); done (0); case VERSIONSW: print_version(invo_name); done (0); case AUTOSW: autosw++; continue; case NAUTOSW: autosw = 0; continue; case RCACHESW: icachesw = &rcachesw; goto do_cache; case WCACHESW: icachesw = &wcachesw; do_cache: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); switch (*icachesw = smatch (cp, caches)) { case AMBIGSW: ambigsw (cp, caches); done (1); case UNKWNSW: adios (NULL, "%s unknown", cp); default: break; } continue; case CHECKSW: checksw++; continue; case NCHECKSW: checksw = 0; continue; case PARTSW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); if (npart >= NPARTS) adios (NULL, "too many parts (starting with %s), %d max", cp, NPARTS); parts[npart++] = cp; continue; case TYPESW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); if (ntype >= NTYPES) adios (NULL, "too many types (starting with %s), %d max", cp, NTYPES); types[ntype++] = cp; continue; case FILESW: if (!(cp = *argp++) || (*cp == '-' && cp[1])) adios (NULL, "missing argument to %s", argp[-2]); file = *cp == '-' ? cp : path (cp, TFILE); continue; case OUTFILESW: if (!(cp = *argp++) || (*cp == '-' && cp[1])) adios (NULL, "missing argument to %s", argp[-2]); outfile = *cp == '-' ? cp : path (cp, TFILE); continue; case VERBSW: verbosw = 1; continue; case NVERBSW: verbosw = 0; continue; case CLOBBERSW: if (!(cp = *argp++) || *cp == '-') adios (NULL, "missing argument to %s", argp[-2]); if (save_clobber_policy (cp)) { adios (NULL, "invalid argument, %s, to %s", argp[-1], argp[-2]); } continue; case DEBUGSW: debugsw = 1; continue; } } if (*cp == '+' || *cp == '@') { if (folder) adios (NULL, "only one folder at a time!"); else folder = pluspath (cp); } else app_msgarg(&msgs, cp); } /* null terminate the list of acceptable parts/types */ parts[npart] = NULL; types[ntype] = NULL; /* * Check if we've specified an additional profile */ if ((cp = getenv ("MHSTORE"))) { if ((fp = fopen (cp, "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); } else { admonish ("", "unable to read $MHSTORE profile (%s)", cp); } } /* * Read the standard profile setup */ if ((fp = fopen (cp = etcpath ("mhn.defaults"), "r"))) { readconfig ((struct node **) 0, fp, cp, 0); fclose (fp); } /* Check for public cache location */ if ((cache_public = context_find (nmhcache)) && *cache_public != '/') cache_public = NULL; /* Check for private cache location */ if (!(cache_private = context_find (nmhprivcache))) cache_private = ".cache"; cache_private = getcpy (m_maildir (cache_private)); /* * Cache the current directory before we do any chdirs()'s. */ cwd = getcpy (pwd()); if (!context_find ("path")) free (path ("./", TFOLDER)); if (file && msgs.size) adios (NULL, "cannot specify msg and file at same time!"); /* * check if message is coming from file */ if (file) { if (!(cts = (CT *) calloc ((size_t) 2, sizeof(*cts)))) adios (NULL, "out of memory"); ctp = cts; if ((ct = parse_mime (file))) { *ctp++ = ct; if (outfile) { ct->c_storage = outfile; } } } else { /* * message(s) are coming from a folder */ if (!msgs.size) app_msgarg(&msgs, "cur"); if (!folder) folder = getfolder (1); maildir = m_maildir (folder); if (chdir (maildir) == NOTOK) adios (maildir, "unable to change directory to"); /* read folder and create message structure */ if (!(mp = folder_read (folder, 1))) adios (NULL, "unable to read folder %s", folder); /* check for empty folder */ if (mp->nummsg == 0) adios (NULL, "no messages in %s", folder); /* parse all the message ranges/sequences and set SELECTED */ for (msgnum = 0; msgnum < msgs.size; msgnum++) if (!m_convert (mp, msgs.msgs[msgnum])) done (1); seq_setprev (mp); /* set the previous-sequence */ if (!(cts = (CT *) calloc ((size_t) (mp->numsel + 1), sizeof(*cts)))) adios (NULL, "out of memory"); ctp = cts; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected(mp, msgnum)) { char *msgnam; msgnam = m_name (msgnum); if ((ct = parse_mime (msgnam))) { *ctp++ = ct; if (outfile) { ct->c_storage = add (outfile, NULL); } } } } } if (!*cts) done (1); userrs = 1; SIGNAL (SIGQUIT, quitser); SIGNAL (SIGPIPE, pipeser); /* * Get the associated umask for the relevant contents. */ for (ctp = cts; *ctp; ctp++) { struct stat st; ct = *ctp; if (type_ok (ct, 1) && !ct->c_umask) { if (stat (ct->c_file, &st) != NOTOK) ct->c_umask = ~(st.st_mode & 0777); else ct->c_umask = ~m_gmprot(); } } /* * Store the message content */ store_all_messages (cts); /* Now free all the structures for the content */ for (ctp = cts; *ctp; ctp++) free_content (*ctp); free ((char *) cts); cts = NULL; /* If reading from a folder, do some updating */ if (mp) { context_replace (pfolder, folder);/* update current folder */ seq_setcur (mp, mp->hghsel); /* update current message */ seq_save (mp); /* synchronize sequences */ context_save (); /* save the context file */ } done (files_not_clobbered); return 1; }
int what_now (char *ed, int nedit, int use, char *file, char *altmsg, int dist, struct msgs *mp, char *text, int inplace, char *cwd) { int found, k, msgnum, vecp; int len, buflen; register char *bp; char buffer[BUFSIZ], *vec[MAXARGS]; vecp = 0; vec[vecp++] = r1bindex (whatnowproc, '/'); vec[vecp] = NULL; m_putenv ("mhdraft", file); if (mp) m_putenv ("mhfolder", mp->foldpath); else unputenv ("mhfolder"); if (altmsg) { if (mp == NULL || *altmsg == '/' || cwd == NULL) m_putenv ("mhaltmsg", altmsg); else { snprintf (buffer, sizeof(buffer), "%s/%s", mp->foldpath, altmsg); m_putenv ("mhaltmsg", buffer); } } else { unputenv ("mhaltmsg"); } if ((bp = getenv ("mhaltmsg")))/* XXX */ m_putenv ("editalt", bp); snprintf (buffer, sizeof(buffer), "%d", dist); m_putenv ("mhdist", buffer); if (nedit) { unputenv ("mheditor"); } else { m_putenv ("mheditor", ed ? ed : (ed = context_find ("editor")) ? ed : defaulteditor); } snprintf (buffer, sizeof(buffer), "%d", use); m_putenv ("mhuse", buffer); unputenv ("mhmessages"); unputenv ("mhannotate"); unputenv ("mhinplace"); if (text && mp && !is_readonly(mp)) { found = 0; bp = buffer; buflen = sizeof(buffer); for (msgnum = mp->lowmsg; msgnum <= mp->hghmsg; msgnum++) { if (is_selected(mp, msgnum)) { snprintf (bp, buflen, "%s%s", found ? " " : "", m_name (msgnum)); len = strlen (bp); bp += len; buflen -= len; for (k = msgnum + 1; k <= mp->hghmsg && is_selected(mp, k); k++) continue; if (--k > msgnum) { snprintf (bp, buflen, "-%s", m_name (k)); len = strlen (bp); bp += len; buflen -= len; } msgnum = k + 1; found++; } } if (found) { m_putenv ("mhmessages", buffer); m_putenv ("mhannotate", text); snprintf (buffer, sizeof(buffer), "%d", inplace); m_putenv ("mhinplace", buffer); } } context_save (); /* save the context file */ fflush (stdout); if (cwd) chdir (cwd); /* * If the "whatnowproc" is the nmh command "whatnow", * we run it internally, rather than exec'ing it. */ if (strcmp (vec[0], "whatnow") == 0) { WhatNow (vecp, vec); done (0); } execvp (whatnowproc, vec); fprintf (stderr, "unable to exec "); perror (whatnowproc); return 0; }
void KlassInfoHisto::print_class_stats(outputStream* st, bool csv_format, const char *columns) { ResourceMark rm; KlassSizeStats sz, sz_sum; int i; julong *col_table = (julong*)(&sz); julong *colsum_table = (julong*)(&sz_sum); int width_table[KlassSizeStats::_num_columns]; bool selected[KlassSizeStats::_num_columns]; _selected_columns = columns; memset(&sz_sum, 0, sizeof(sz_sum)); for (int c=0; c<KlassSizeStats::_num_columns; c++) { selected[c] = is_selected(name_table[c]); } for(i=0; i < elements()->length(); i++) { elements()->at(i)->set_index(i+1); } // First iteration is for accumulating stats totals in colsum_table[]. // Second iteration is for printing stats for each class. for (int pass=1; pass<=2; pass++) { if (pass == 2) { print_title(st, csv_format, selected, width_table, name_table); } for(i=0; i < elements()->length(); i++) { KlassInfoEntry* e = (KlassInfoEntry*)elements()->at(i); const Klass* k = e->klass(); // Get the stats for this class. memset(&sz, 0, sizeof(sz)); sz._inst_count = e->count(); sz._inst_bytes = HeapWordSize * e->words(); k->collect_statistics(&sz); sz._total_bytes = sz._ro_bytes + sz._rw_bytes; if (pass == 1) { // Add the stats for this class to the overall totals. for (int c=0; c<KlassSizeStats::_num_columns; c++) { colsum_table[c] += col_table[c]; } } else { int super_index = -1; // Print the stats for this class. if (k->is_instance_klass()) { Klass* super = k->super(); if (super) { KlassInfoEntry* super_e = _cit->lookup(super); if (super_e) { super_index = super_e->index(); } } } if (csv_format) { st->print("%ld,%d", e->index(), super_index); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);} } st->print(",%s",e->name()); } else { st->print("%5ld %5d", e->index(), super_index); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {print_julong(st, width_table[c], col_table[c]);} } st->print(" %s", e->name()); } if (is_selected("ClassLoader")) { ClassLoaderData* loader_data = k->class_loader_data(); st->print(","); loader_data->print_value_on(st); } st->cr(); } } if (pass == 1) { // Calculate the minimum width needed for the column by accounting for the // column header width and the width of the largest value in the column. for (int c=0; c<KlassSizeStats::_num_columns; c++) { width_table[c] = col_width(colsum_table[c], name_table[c]); } } } sz_sum._inst_size = 0; // Print the column totals. if (csv_format) { st->print(","); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print("," JULONG_FORMAT, colsum_table[c]);} } } else { st->print(" "); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {print_julong(st, width_table[c], colsum_table[c]);} } st->print(" Total"); if (sz_sum._total_bytes > 0) { st->cr(); st->print(" "); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) { switch (c) { case KlassSizeStats::_index_inst_size: case KlassSizeStats::_index_inst_count: case KlassSizeStats::_index_method_count: st->print("%*s", width_table[c], "-"); break; default: { double perc = (double)(100) * (double)(colsum_table[c]) / (double)sz_sum._total_bytes; st->print("%*.1f%%", width_table[c]-1, perc); } } } } } } st->cr(); if (!csv_format) { print_title(st, csv_format, selected, width_table, name_table); } }
void CGppe::Elicit( const VectorXd & theta_x, const VectorXd& theta_t, const double& sigma, const MatrixXd& train_t, const MatrixXd &x, TypePair & train_pairs , const MatrixXd & test_t, int test_user_idx, MatrixXd idx_pairs, int Maxiter, const TypePair& Oracle , MatrixXd& F) { train_pairs.conservativeResize(train_pairs.rows()+1); int N = x.rows(); int Mtrain = train_t.rows(); int M = Mtrain + 1; int Npairs = idx_pairs.rows(); int Lgood; VectorXd vrand, idx_good; //VectorXd is_selected(Npairs); Matrix<bool, Dynamic, 1> is_selected(Npairs); is_selected.fill(false); VectorXd loss = VectorXd::Zero(Maxiter + 1); double loss_current; VectorXd evoi(Npairs), ind_t, ind_x; VectorXd idx_global_1, idx_global_2, idx_global; compute_global_index(idx_global_1, idx_global_2, train_pairs, N); unique(idx_global, idx_global_1, idx_global_2); ind2sub(ind_x, ind_t, N, M, idx_global); bool stop = false; double foo, val; int count = 0; MatrixXd new_pair; MatrixXd t; VectorXd p_12(Npairs); t.resize(M, train_t.cols()); t << train_t, test_t; for (int iter = 0;iter <= Maxiter;iter++) { Approx_CGppe_Laplace( theta_x, theta_t, sigma, t, x, train_pairs, idx_global, idx_global_1, idx_global_2, ind_t, ind_x, Mtrain, N); Predictive_Utility_Distribution(t, test_t, N, idx_global ); //dsp(mustar,"mustar"); //dsp(varstar,"varstar"); std::ptrdiff_t best_item_idx; foo = mustar.maxCoeff(&best_item_idx); double fbest = get_fbest(N); //dsp(fbest,"fbest"); MatrixXd test_pair; for (int i = 0;i < Npairs;i++) { Predict_CGppe_Laplace(sigma, t, x, idx_global, ind_t, ind_x, t.row(M-1), idx_pairs.row(i)); p_12(i)=p; } for (int i = 0;i < Npairs;i++) { if (is_selected(i)) { evoi(i) = INT_MIN; continue; } test_pair = idx_pairs.row(i); evoi(i) = expected_voi(theta_x, theta_t, sigma, t, x, train_pairs, idx_global, ind_t, ind_x, test_pair, fbest,p_12(i)); } //dsp(evoi,"evoi"); std::ptrdiff_t query_idx; val = evoi.maxCoeff(&query_idx); idx_good = find(evoi, val); //dsp(val,"val"); Lgood = idx_good.rows(); if ( Lgood > 1) { //vrand = randperm(Lgood); cout<<"Solving clashes at random"<<endl; //query_idx = idx_good(vrand(0)); query_idx = idx_good(0); } is_selected(query_idx) = true; //dsp(query_idx,"queryidx"); new_pair = make_query_toydata(Oracle, query_idx, test_user_idx); //adding the new pair train_pairs(M-1)=MatAdd(train_pairs(M-1),new_pair); compute_global_index(idx_global_1, idx_global_2, train_pairs, N); unique(idx_global, idx_global_1, idx_global_2); ind2sub(ind_x, ind_t, N, M, idx_global); //Computes the loss of making a recommendation at this point loss_query_toydata(loss_current, F, stop, test_user_idx, best_item_idx); loss(iter)=loss_current; count++; cout << "Query " << count << "[" << new_pair(0) << " " << new_pair(1) << "] done, Recommended Item= " << best_item_idx << ", loss=" << loss(iter) << endl; } }
/** * Toggles the selection state of an item. * * @param index The item to toggle. */ void toggle_item(const unsigned index) { select_item(index, !is_selected(index)); }
bool is_playing( const T &anim ) const { return is_animation_playing() && is_selected( anim ); }
bool is_playing( const T &anim, const T2 &anim2, const T3 &anim3 ) const { return is_animation_playing() && is_selected( anim, anim2, anim3 ); }
void KlassInfoHisto::print_class_stats(outputStream* st, bool csv_format, const char *columns) { ResourceMark rm; KlassSizeStats sz, sz_sum; int i; julong *col_table = (julong*)(&sz); julong *colsum_table = (julong*)(&sz_sum); int width_table[KlassSizeStats::_num_columns]; bool selected[KlassSizeStats::_num_columns]; _selected_columns = columns; memset(&sz_sum, 0, sizeof(sz_sum)); for (int c=0; c<KlassSizeStats::_num_columns; c++) { selected[c] = is_selected(name_table[c]); } for(i=0; i < elements()->length(); i++) { elements()->at(i)->set_index(i+1); } for (int pass=1; pass<=2; pass++) { if (pass == 2) { print_title(st, csv_format, selected, width_table, name_table); } for(i=0; i < elements()->length(); i++) { KlassInfoEntry* e = (KlassInfoEntry*)elements()->at(i); const Klass* k = e->klass(); memset(&sz, 0, sizeof(sz)); sz._inst_count = e->count(); sz._inst_bytes = HeapWordSize * e->words(); k->collect_statistics(&sz); sz._total_bytes = sz._ro_bytes + sz._rw_bytes; if (pass == 1) { for (int c=0; c<KlassSizeStats::_num_columns; c++) { colsum_table[c] += col_table[c]; } } else { int super_index = -1; if (k->oop_is_instance()) { Klass* super = ((InstanceKlass*)k)->java_super(); if (super) { KlassInfoEntry* super_e = _cit->lookup(super); if (super_e) { super_index = super_e->index(); } } } if (csv_format) { st->print("%d,%d", e->index(), super_index); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);} } st->print(",%s",e->name()); } else { st->print("%5d %5d", e->index(), super_index); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {print_julong(st, width_table[c], col_table[c]);} } st->print(" %s", e->name()); } if (is_selected("ClassLoader")) { ClassLoaderData* loader_data = k->class_loader_data(); st->print(","); loader_data->print_value_on(st); } st->cr(); } } if (pass == 1) { for (int c=0; c<KlassSizeStats::_num_columns; c++) { width_table[c] = col_width(colsum_table[c], name_table[c]); } } } sz_sum._inst_size = 0; if (csv_format) { st->print(","); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {st->print("," JULONG_FORMAT, colsum_table[c]);} } } else { st->print(" "); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) {print_julong(st, width_table[c], colsum_table[c]);} } st->print(" Total"); if (sz_sum._total_bytes > 0) { st->cr(); st->print(" "); for (int c=0; c<KlassSizeStats::_num_columns; c++) { if (selected[c]) { switch (c) { case KlassSizeStats::_index_inst_size: case KlassSizeStats::_index_inst_count: case KlassSizeStats::_index_method_count: PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL st->print(str_fmt(width_table[c]), "-"); PRAGMA_DIAG_POP break; default: { double perc = (double)(100) * (double)(colsum_table[c]) / (double)sz_sum._total_bytes; PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL st->print(perc_fmt(width_table[c]), perc); PRAGMA_DIAG_POP } } } } } }
void affiche_groupe(TxPoint point, type_groupe * groupe, TxDonneesFenetre *onglet_leto) { TxPoint point2, point3, point4, point5, point6, point7; int type, text_color; const char *font_weight = NULL; point.x = point.x - deltax; point.y = point.y - deltay; point2.x = point.x + deltax / 3; /* position de l'ecriture du no du gpe */ point2.y = point.y + 3 * deltay / 2; point3.x = point.x - distc; point3.y = point.y + 2 * deltay; point4.x = point.x + 2 * deltax + distc; point4.y = point.y + deltay; point5.x = point.x + 2 * deltax + distc; point5.y = point.y + 3 * deltay; type = groupe->type % 30; if (is_selected(groupe) != NULL) { font_weight = "bold"; text_color = noir; TxDessinerRectangle(onglet_leto, lut_g[type], TRUE, point, 2 * deltax + 1, 2 * deltay, 1); } else { text_color = lut_g[type]; TxDessinerRectangle(onglet_leto, lut_g[type], FALSE, point, 2 * deltax, 2 * deltay, 1); } point.y = point.y + 2 * deltay; TxDessinerRectangle(onglet_leto, lut_g[type], 0, point, 2 * deltax, 2 * deltay, 1); point.y = point3.y; if (groupe->reverse <= 0) { if (groupe->type != No_Entree) { TxDessinerCercle(onglet_leto, lut_g[type], TxPlein, point3, 4, 1); TxDessinerSegment(onglet_leto, lut_g[type], point3, point, 1); } FlecheHorizontale(onglet_leto, lut_g[type], point4, 6, 2); point.x = point.x + 2 * deltax; point.y = point4.y; TxDessinerSegment(onglet_leto, lut_g[type], point4, point, 1); FlecheHorizontale(onglet_leto, lut_g[type], point5, 6, 2); point.y = point5.y; TxDessinerSegment(onglet_leto, lut_g[type], point5, point, 1); } else if (groupe->reverse > 0) { point3.y = point3.y - deltay; FlecheHorizontale(onglet_leto, lut_g[type], point3, -6, 2); point.x = point3.x + distc; point.y = point3.y; TxDessinerSegment(onglet_leto, lut_g[type], point3, point, 1); point3.y = point3.y + 2 * deltay; FlecheHorizontale(onglet_leto, lut_g[type], point3, -6, 2); point.y = point3.y; TxDessinerSegment(onglet_leto, lut_g[type], point3, point, 1); if (groupe->type != No_Entree) { point4.y = point4.y + deltax; point.y = point4.y; point.x = point4.x - distc; TxDessinerCercle(onglet_leto, lut_g[type], TxPlein, point4, 4, 1); TxDessinerSegment(onglet_leto, lut_g[type], point4, point, 1); } } TxEcrireChaine(onglet_leto, text_color, point2, groupe->no_name, NULL); #ifndef SYMBOLIQUE_VERSION if (groupe->taillex > 1 || groupe->tailley > 1) { point6.x = point2.x; point6.y = point2.y + 2 * deltax + 1; if (groupe->taillex > 1) { point7.x = point6.x + 7; point7.y = point6.y; TxDessinerSegment(onglet_leto, lut_g[type], point6, point7, 1); point7.x = point7.x + 7; FlecheHorizontale(onglet_leto, lut_g[type], point7, 1, 1); } if (groupe->tailley > 1) { point7.x = point6.x; point7.y = point6.y - 7; TxDessinerSegment(onglet_leto, lut_g[type], point6, point7, 1); point7.y = point7.y - 7; FlecheVerticale(onglet_leto, lut_g[type], point7, -1, 1); } } else { point6.x = point2.x + 5; point6.y = point2.y + 15; TxDessinerCercle(onglet_leto, lut_g[type], TxPlein, point6, 2, 1); } #else if (!verify_if_int(groupe->taillex) || !verify_if_int(groupe->tailley) || (MY_Int2Int(groupe->taillex) > 1) || (MY_Int2Int(groupe->tailley) > 1)) { point6.x = point2.x; point6.y = point2.y + 2 * deltax + 1; if (!verify_if_int(groupe->taillex) || (MY_Int2Int(groupe->taillex) > 1)) { point7.x = point6.x + 7; point7.y = point6.y; TxDessinerSegment(onglet_leto, lut_g[type], point6, point7, 1); point7.x = point7.x + 7; FlecheHorizontale(onglet_leto, lut_g[type], point7, 1, 1); } if (!verify_if_int(groupe->tailley) || (MY_Int2Int(groupe->tailley) > 1)) { point7.x = point6.x; point7.y = point6.y - 7; TxDessinerSegment(onglet_leto, lut_g[type], point6, point7, 1); point7.y = point7.y - 7; FlecheVerticale(onglet_leto, lut_g[type], point7, -1, 1); } } else { point6.x = point2.x + 5; point6.y = point2.y + 15; TxDessinerCercle(onglet_leto, lut_g[type], TxPlein, point6, 2, 1); } #endif point3.x = point3.x /*+ deltax*/; point3.y = point3.y + 3 * (deltay + 1); TxEcrireChaine(onglet_leto, lut_g[type]/*sc->couleur_texte*/, point3, groupe->nom, (char*)font_weight); }
bool has_played( const T &anim, const T2 &anim2, const T3 &anim3 ) const { return has_animation_played() && is_selected( anim, anim2, anim3 ); }