int main() { { boost::fusion::vector<int, short, double> t(1, 2, 3.3); BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 > 4))); BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 < 0))); } { boost::fusion::vector<int, short, double> t(1, 2, 3.3); BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 == 1))); BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3))); } { typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec; // We cannot use lambda here as mpl vec iterators return // rvalues, and lambda needs lvalues. BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4))); BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3))); } return boost::report_errors(); }
std::string gphandle::generate_back() { int grass_sprites_size = 9; std::string grass_loc = search_for("grass", "dirs.txt"); ALLEGRO_BITMAP *grass_img = al_load_bitmap(grass_loc.c_str()); std::vector<ALLEGRO_BITMAP *> grasses(grass_sprites_size); for(int i=0; i<grass_sprites_size; i++) { grasses[i] = al_create_sub_bitmap(grass_img, i*32, 0, (i+1)*32, 32); } ALLEGRO_BITMAP *new_back = al_create_bitmap(1024, 768); al_set_target_bitmap(new_back); srand(time(NULL)); for(int i=0; i<24; i++){ for(int j=0; j<32; j++) { int random = rand()%grass_sprites_size; al_draw_bitmap(grasses[random], 32.0 * j, 32.0 * i,0); } } std::string location = "tmps/background.png"; al_save_bitmap(location.c_str(), new_back); return location; }
void showing_propsheet_update_search_for(HWND hWnd) { if (canCreateFindWindow) return; if (hWnd) { search_for(hWnd); clear_mark(hWnd); my_mark_all_matches_for_text(hWnd); } }
bool redblacktree::ispresent(int const value){ //Funkcja sprawdza czy wezel o zadanej wartosci nalezy do drzewa if(search_for(value) == this->getsentinel()){ std::cout << "Szukana Wartosc: " << value << " NIE nalezy do drzewa" << std::endl; return false; } else{ std::cout << "Szukana Wartosc: " << value << " nalezy do drzewa" << std::endl; return true; } }
static void text_string_notif_proc(HWND hWnd, int id, int nc, DWORD add_data) { if (nc == EN_CHANGE) { get_search_string(hWnd); HWND mdolphin_chwnd = get_current_mdolphin_hwnd(); if (!mdolphin_chwnd) return; search_for(mdolphin_chwnd); clear_mark(mdolphin_chwnd); my_mark_all_matches_for_text(mdolphin_chwnd); } }
static int InitDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam) { switch (message) { case MSG_INITDIALOG: RECT rc; GetWindowRect ((HWND)(lParam), &rc); MoveWindow (hDlg , (rc.right-rc.left)/2-160 , (rc.bottom-rc.top)/2-60 , 320 , 120 , TRUE); init_parameter_for_find(hDlg); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_TEXT), text_string_notif_proc); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_CASE), case_sensitive_notif_proc); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_WRAP), wrap_notif_proc); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_ALL), mark_all_notif_proc); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_UP), forward_notif_proc); SetNotificationCallback (GetDlgItem (hDlg, IDC_FIND_DOWN), forward_notif_proc); return 1; case MSG_COMMAND: switch (wParam) { case IDC_FIND_NEXT: { HWND mdolphin_chwnd = get_current_mdolphin_hwnd(); if (mdolphin_chwnd) search_for(mdolphin_chwnd); } break; } break; case MSG_DESTROY: DestroyAllControls(hDlg); return 0; case MSG_CLOSE: { canCreateFindWindow = TRUE; SetWindowText (status_hwnd, ""); SendMessage(propsheet_hwnd, PSM_SHEETCMD, USER_PMS_CLOSE_SEARCHFOR, 0); DestroyMainWindowIndirect(hDlg); } return 0; } return DefaultWindowProc (hDlg, message, wParam, lParam); }
void redblacktree::remove_node(int value){ //Funkcja usuwa wezel zachowujac wlasnosci czerwono-czarne rbtnode *help1, *help2, *help3; rbtnode* removed = search_for(value); if(removed == this->getsentinel()){ return; } if( (removed->getleft() == this->getsentinel()) || (removed->getright() == this->getsentinel()) ){ help2 = removed; } else{ help2 = successor(removed); } if(help2->getleft() != this->getsentinel()){ help3 = help2->getleft(); } else{ help3 = help2->getright(); } help3->setfather(help2->getfather() ); if(help2->getfather() == this->getsentinel()){ this->setroot(help3); } else if(help2 == help2->getfather()->getleft()){ help2->getfather()->setleft(help3); } else{ help2->getfather()->setright(help3); } if(help2 != removed){ removed->setvalue(help2->getvalue()); } if(help2->getcolor() == 'b'){ while((help3 != this->getroot()) && (help3->getcolor() == 'b')){ if(help3 == help3->getfather()->getleft()){ help1 = help3->getfather()->getright(); if(help1->getcolor() == 'r'){ // Przypadek 1 help1->setcolor('b'); help3->getfather()->setcolor('r'); rotate_left(help3->getfather()); help1 = help3->getfather()->getright(); } if( (help1->getleft()->getcolor() == 'b') && (help1->getright()->getcolor() == 'b') ){ // Przypadek 2 help1->setcolor('r'); help3 = help3->getfather(); continue; } if(help1->getright()->getcolor() == 'b'){ // Przypadek 3 help1->getleft()->setcolor('b'); help1->setcolor('r'); rotate_right(help1); help1 = help3->getfather()->getright(); } help1->setcolor(help3->getfather()->getcolor()); // Przypadek 4 help3->getfather()->setcolor('b'); help1->getright()->setcolor('b'); rotate_left(help3->getfather()); help3 = this->getroot(); //Przerywa } else{ // Przypadki lustrzane help1 = help3->getfather()->getleft(); if(help1->getcolor() == 'r'){ // Przypadek 1 help1->setcolor('b'); help3->getfather()->setcolor('r'); rotate_right(help3->getfather()); help1 = help3->getfather()->getleft(); } if( (help1->getleft()->getcolor() == 'b') && (help1->getright()->getcolor() == 'b') ){ help1->setcolor('r'); help3 = help3->getfather(); continue; } if(help1->getleft()->getcolor() == 'b'){ // Przypadek 3 help1->getright()->setcolor('b'); help1->setcolor('r'); rotate_left(help1); help1 = help3->getfather()->getleft(); } help1->setcolor( help3->getfather()->getcolor()); // Przypadek 4 help3->getfather()->setcolor('b'); help1->getleft()->setcolor('b'); rotate_right(help3->getfather()); help3 =this->getroot(); //Przerwanie } } } help3->setcolor('b'); delete help2; }
int main(int argc, char **argv) { environment e; machine m; char *archive; environment_at_startup(); e = environment_new(); m = machine_new(e); environment_setup_thread(e, m); machine_setup_normal(m, argc, argv); /* We build up the environment information by looking around * the filesystem now. */ /* Find the platform config */ e->platform_config = search_for("RBX_PLATFORM_CONF", "platform.conf"); /* Find the bootstrap. */ archive = search_for("RBX_BOOTSTRAP", "bootstrap"); if(!archive) { printf("Unable to find a bootstrap to load!\n"); return 1; } e->bootstrap_path = archive; /* Find the platform. */ archive = search_for("RBX_PLATFORM", "platform"); if(!archive) { printf("Unable to find a platform to load!\n"); return 1; } e->platform_path = archive; /* Find the core. */ archive = search_for("RBX_CORE", "core"); if(!archive) { printf("Unable to find a core to load!\n"); return 1; } e->core_path = archive; /* Load the loader.rbc */ archive = search_for("RBX_LOADER", "loader.rbc"); if(!archive) { printf("Unable to find loader.rbc to load!\n"); return 1; } e->loader_path = archive; environment_load_machine(e, m); /* Done! */ if(m->s->gc_stats) { printf("[GC M %6dK total]\n", m->s->om->ms->allocated_bytes); } return 0; }
/** * Load configuration file from "~/.tlkgames/powermanga.conf" * @return TRUE if it completed successfully or FALSE otherwise */ bool configfile_load (void) { #if !defined(_WIN32_WCE) Uint32 length; #endif lisp_object_t *root_obj, *lst, *sub; char *str; /* allocate config structure */ if (power_conf == NULL) { power_conf = (config_file *) memory_allocation (sizeof (config_file)); if (power_conf == NULL) { LOG_ERR ("not enough memory to allocate 'power_conf'!"); return FALSE; } } configfile_reset_values (); if (!configfile_check_dir ()) { return TRUE; } if (configname == NULL) { #if defined(_WIN32_WCE) configname = locate_data_file (config_file_name); if (configname == NULL) { LOG_ERR ("can't locate file: %s", config_file_name); return FALSE; } #else length = strlen (config_dir) + strlen (config_file_name) + 2; configname = memory_allocation (length); if (configname == NULL) { LOG_ERR ("not enough memory to allocate %i bytes!", length); return FALSE; } #endif } sprintf (configname, "%s/%s", config_dir, config_file_name); LOG_INF ("configuration filename: %s", configname); root_obj = lisp_read_file (configname); if (root_obj == NULL) { LOG_ERR ("lisp_read_file(%s) failed!", configname); return TRUE; } if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) { LOG_ERR ("lisp_read_file(%s) failed!", configname); lisp_free (root_obj); return TRUE; } if (strcmp (lisp_symbol (lisp_car (root_obj)), "powermanga-config") != 0) { LOG_ERR ("lisp_read_file(%s) failed!", configname); lisp_free (root_obj); return TRUE; } lst = lisp_cdr (root_obj); if (!lisp_read_string (lst, "lang", &str)) { power_conf->lang = EN_LANG; } else { if (strcmp (str, "fr") == 0) { power_conf->lang = FR_LANG; } else if (strcmp (str, "it") == 0) { power_conf->lang = IT_LANG; } else { power_conf->lang = EN_LANG; } } if (!lisp_read_bool (lst, "fullscreen", &power_conf->fullscreen)) { power_conf->fullscreen = TRUE; } if (!lisp_read_bool (lst, "nosound", &power_conf->nosound)) { power_conf->nosound = FALSE; } if (!lisp_read_bool (lst, "nosync", &power_conf->nosync)) { power_conf->nosync = FALSE; } if (!lisp_read_int (lst, "verbose", &power_conf->verbose)) { power_conf->verbose = 0; } if (!lisp_read_int (lst, "scale_x", &power_conf->scale_x)) { power_conf->scale_x = 2; } if (power_conf->scale_x < 1 || power_conf->scale_x > 4) { power_conf->scale_x = 2; } if (!lisp_read_int (lst, "resolution", &power_conf->resolution)) { power_conf->resolution = 640; } if (power_conf->resolution != 320 && power_conf->resolution != 640) { power_conf->resolution = 640; } if (power_conf->scale_x > 1) { power_conf->resolution = 640; } sub = search_for (lst, "joy_config"); if (sub) sub = lisp_car_int (sub, &power_conf->joy_x_axis); if (sub) sub = lisp_car_int (sub, &power_conf->joy_y_axis); if (sub) sub = lisp_car_int (sub, &power_conf->joy_fire); if (sub) sub = lisp_car_int (sub, &power_conf->joy_option); if (sub) sub = lisp_car_int (sub, &power_conf->joy_start); lisp_free (root_obj); configfile_print(); return TRUE; }