value_comparison(KeyFromValue key_=KeyFromValue(),Compare comp_=Compare()): key(key_),comp(comp_) { }
int equal(const char *s1, const char *s2) { return Compare(s1, s2) == 0; }
int Compare(LPARAM lParam1, LPARAM lParam2) { return Compare( (CShadowTree*)m_pList->GetItemData((int)lParam1), (CShadowTree*)m_pList->GetItemData((int)lParam2)); }
int String::Compare(const char* str, bool caseSensitive) const { return Compare(CString(), str, caseSensitive); }
// key -> value access value_ref_type operator[]( key_param_type key ) const { iterator it = boost::detail::lower_bound( m_map.begin(), m_map.end(), key, p1() ); return (it == m_map.end() || Compare()( key, it->first ) ) ? m_invalid_value : it->second; }
main(int argc, char **argv) { l_int32 error; l_uint32 *data; PIX *pix1, *pix2, *pix3, *pix1c, *pix2c, *pix1t, *pix2t, *pixd; PIXA *pixa; static char mainName[] = "pixmem_reg"; error = 0; pixa = pixaCreate(0); /* Copy with internal resizing: onto a cmapped image */ pix1 = pixRead("weasel4.16c.png"); pix2 = pixRead("feyn-fract.tif"); pix3 = pixRead("lucasta.150.jpg"); fprintf(stderr, "before copy 2 --> 3\n"); pixCopy(pix3, pix2); Compare(pix2, pix3, &error); pixSaveTiled(pix3, pixa, 4, 1, 30, 32); fprintf(stderr, "before copy 3 --> 1\n"); pixCopy(pix1, pix3); Compare(pix2, pix1, &error); pixSaveTiled(pix1, pixa, 4, 0, 30, 32); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); /* Copy with internal resizing: from a cmapped image */ pix1 = pixRead("weasel4.16c.png"); pix2 = pixRead("feyn-fract.tif"); pix3 = pixRead("lucasta.150.jpg"); fprintf(stderr, "before copy 1 --> 2\n"); pixCopy(pix2, pix1); Compare(pix2, pix1, &error); pixSaveTiled(pix2, pixa, 1, 1, 30, 32); fprintf(stderr, "before copy 2 --> 3\n"); pixCopy(pix3, pix2); Compare(pix3, pix2, &error); pixSaveTiled(pix3, pixa, 1, 0, 30, 32); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); /* Transfer of data pixs --> pixd, when pixs is not cloned. * pixs is destroyed. */ pix1 = pixRead("weasel4.16c.png"); pix2 = pixRead("feyn-fract.tif"); pix3 = pixRead("lucasta.150.jpg"); pix1c = pixCopy(NULL, pix1); fprintf(stderr, "before transfer 1 --> 2\n"); pixTransferAllData(pix2, &pix1, 0, 0); Compare(pix2, pix1c, &error); pixSaveTiled(pix2, pixa, 1, 1, 30, 32); fprintf(stderr, "before transfer 2 --> 3\n"); pixTransferAllData(pix3, &pix2, 0, 0); Compare(pix3, pix1c, &error); pixSaveTiled(pix3, pixa, 1, 0, 30, 32); pixDestroy(&pix1c); pixDestroy(&pix3); /* Another transfer of data pixs --> pixd, when pixs is not cloned. * pixs is destroyed. */ pix1 = pixRead("weasel4.16c.png"); pix2 = pixRead("feyn-fract.tif"); pix3 = pixRead("lucasta.150.jpg"); pix1c = pixCopy(NULL, pix1); pix2c = pixCopy(NULL, pix2); fprintf(stderr, "before copy transfer 1 --> 2\n"); pixTransferAllData(pix2, &pix1c, 0, 0); Compare(pix2, pix1, &error); pixSaveTiled(pix2, pixa, 1, 0, 30, 32); fprintf(stderr, "before copy transfer 2 --> 3\n"); pixTransferAllData(pix3, &pix2, 0, 0); Compare(pix3, pix1, &error); pixSaveTiled(pix3, pixa, 1, 0, 30, 32); pixDestroy(&pix1); pixDestroy(&pix2c); pixDestroy(&pix3); /* Transfer of data pixs --> pixd, when pixs is cloned. * pixs has its refcount reduced by 1. */ pix1 = pixRead("weasel4.16c.png"); pix2 = pixRead("feyn-fract.tif"); pix3 = pixRead("lucasta.150.jpg"); pix1c = pixClone(pix1); pix2c = pixClone(pix2); fprintf(stderr, "before clone transfer 1 --> 2\n"); pixTransferAllData(pix2, &pix1c, 0, 0); Compare(pix2, pix1, &error); pixSaveTiled(pix2, pixa, 1, 0, 30, 32); fprintf(stderr, "before clone transfer 2 --> 3\n"); pixTransferAllData(pix3, &pix2c, 0, 0); Compare(pix3, pix1, &error); pixSaveTiled(pix3, pixa, 1, 0, 30, 32); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); /* Extraction of data when pixs is not cloned, putting * the data into a new template of pixs. */ pix2 = pixRead("feyn-fract.tif"); fprintf(stderr, "no clone: before extraction and reinsertion of 2\n"); pix2c = pixCopy(NULL, pix2); /* for later reference */ data = pixExtractData(pix2); pix2t = pixCreateTemplateNoInit(pix2); pixFreeData(pix2t); pixSetData(pix2t, data); Compare(pix2c, pix2t, &error); pixSaveTiled(pix2t, pixa, 4, 1, 30, 32); pixDestroy(&pix2); pixDestroy(&pix2c); pixDestroy(&pix2t); /* Extraction of data when pixs is cloned, putting * a copy of the data into a new template of pixs. */ pix1 = pixRead("weasel4.16c.png"); fprintf(stderr, "clone: before extraction and reinsertion of 1\n"); pix1c = pixClone(pix1); /* bump refcount of pix1 to 2 */ data = pixExtractData(pix1); /* should make a copy of data */ pix1t = pixCreateTemplateNoInit(pix1); pixFreeData(pix1t); pixSetData(pix1t, data); Compare(pix1c, pix1t, &error); pixSaveTiled(pix1t, pixa, 1, 0, 30, 32); pixDestroy(&pix1); pixDestroy(&pix1c); pixDestroy(&pix1t); pixd = pixaDisplay(pixa, 0, 0); pixDisplay(pixd, 100, 100); pixWrite("/tmp/junkpixmem.png", pixd, IFF_PNG); pixaDestroy(&pixa); pixDestroy(&pixd); if (error) fprintf(stderr, "Fail: an error occurred\n"); else fprintf(stderr, "Success: no errors\n"); return 0; }
static int Cmp_Hi(const void *a, const void *b) { return Compare( Sort_Pts[*(int*)b], Sort_Pts[*(int*)a] ); }
TST_tpRetCode TST_TestSpecific :: PerformSpecificTest( char * Command ) { // Interpret TENV Reset // AE: Reset if ( strcmp( Command , Reset_CMD ) == 0 ) { for ( int i = 0 ; i < TENV_dimVtEnv ; i++ ) { delete vtEnv[ i ] ; vtEnv[ i ] = NULL ; } /* for */ return TST_RetCodeOK ; } // end selection: Interpret TENV Reset // Test: ENV !Environment constructor // AE: NewEnvironment inxEnv else if ( strcmp( Command , ENV_MainEnvironment_002_CMD ) == 0 ) { /***** Function ENV_Environment( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , NO )) { return TST_RetCodeParmError ; } /* if */ vtEnv[ inxEnv ] = new ENV_Environment( ) ; return TST_RetCodeOK ; } // end selection: Test: ENV !Environment constructor // Test: ENV !Environment destructor // AE: DeleteEnvironment inxEnv else if ( strcmp( Command , DeleteENV_003_CMD ) == 0 ) { /***** Function ~ENV_Environment( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , ANY )) { return TST_RetCodeParmError ; } /* if */ delete vtEnv[ inxEnv ] ; vtEnv[ inxEnv ] = NULL ; return TST_RetCodeOK ; } // end selection: Test: ENV !Environment destructor // Test: ENV !Build environment // AE: BuildEnvironment inxEnvironment environmentVarName // if environmentVarName == "." builds with NULL else if ( strcmp( Command , BuildEnvironment_004_CMD ) == 0 ) { struct PointerEnvelope { MSG_Message * pMsg ; STR_String * pStr ; PointerEnvelope( ) { pMsg = NULL ; pStr = NULL ; } ~PointerEnvelope( ) { delete pMsg ; delete pStr ; } } envelope ; /* struct */ /***** Function void BuildEnvironment( char * environmentVarName ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ if ( strcmp( Value , "." ) != 0 ) { envelope.pMsg = vtEnv[ inxEnv ]->BuildEnvironment( Value ) ; } else { envelope.pMsg = vtEnv[ inxEnv ]->BuildEnvironment( NULL ) ; } /* if */ if ( envelope.pMsg != NULL ) { envelope.pStr = envelope.pMsg->AssembleMessage( ) ; DisplayErrorMsg( envelope.pStr->GetString( )) ; return TST_RetCodeFailure ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Build environment // Test: ENV !Set environment empty // AE: SetEmpty inxEnvironment else if ( strcmp( Command , SetEmpty_005_CMD ) == 0 ) { /***** Function void SetEmpty( ) *****/ int inxEnv = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxEnv ) ; if ( ( numRead != 1 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ vtEnv[ inxEnv ]->SetEmpty( ) ; return TST_RetCodeOK ; } // end selection: Test: ENV !Set environment empty // Test: ENV !Get environment variable // AE: GetVariableName inxEnvironment expName // expName == "." displays the name // expName == "" expects NULL name else if ( strcmp( Command , GetVariable_006_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetVariable( ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetVariable( ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment variable name" ) ; } /* if */ if ( strcmp( Value , "" ) != 0 ) { return TST_RetCodeOK ; } /* if */ DisplayErrorMsg( "Variable is NULL." ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment variable name: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "Variable is not set." , "" ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment variable // Test: ENV !Get environment string // AE: GetEnvironmentString inxEnvironment expString // expString == "." displays the string // expString == "" expects NULL string else if ( strcmp( Command , GetString_007_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetString( ) *****/ int inxEnv = -1 ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "is" , &inxEnv , &sizValue , Value ) ; if ( ( numRead != 2 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetString( ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment variable string" ) ; } /* if */ if ( strcmp( Value , "" ) != 0 ) { return TST_RetCodeOK ; } /* if */ DisplayErrorMsg( "String is NULL." ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment variable string: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "String is NULL." , "" ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment string // Test: ENV !Get environment parameter // AE: GetParameter inxEnvironment parameterName expValue else if ( strcmp( Command , GetParameter_008_CMD ) == 0 ) { struct PointerEnvelope { STR_String * pStr ; PointerEnvelope( ) { pStr = NULL ; } ~PointerEnvelope( ) { delete pStr ; } } envelope ; /* struct */ /***** Function STR_String * GetParameter( char * parameterName ) *****/ int inxEnv = -1 ; int sizParmName = -1 ; char parmName[ TAL_dimBuffer ] ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "iss" , &inxEnv , &sizParmName , parmName , &sizValue , Value ) ; if ( ( numRead != 3 ) || !VerifyInxEnv( inxEnv , YES )) { return TST_RetCodeParmError ; } /* if */ envelope.pStr = vtEnv[ inxEnv ]->GetParameter( parmName ) ; if ( strcmp( Value , "." ) != 0 ) { if ( envelope.pStr != NULL ) { return Compare( envelope.pStr->GetLength( ) , envelope.pStr->GetString( ) , sizValue , Value , "Incorrect environment parameter value." ) ; } /* if */ DisplayErrorMsg( "Did not find parameter: " , parmName ) ; return TST_RetCodeFailure ; } /* if */ if ( envelope.pStr != NULL ) { DisplayInformation( "Environment parameter: " , envelope.pStr->GetString( )) ; } else { DisplayInformation( "Did not find parameter: " , parmName ) ; } /* if */ return TST_RetCodeOK ; } // end selection: Test: ENV !Get environment parameter return TST_RetCodeUnknown ; } // End of function: TENV !P Perform specific test actions
int WebRect::Merge(WebRect *pRect1, WebRect *pRect2) { return (MergeCase(pRect1, pRect2, Compare(pRect1))); }
bool BinaryData::operator<(const BinaryData & inData) const { return Compare(inData) < 0; }
int cbTreeCtrl::OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2) { return Compare(((FileTreeData*)GetItemData(item1))->GetProjectFile(), ((FileTreeData*)GetItemData(item2))->GetProjectFile()); }
bool CDuiString::operator > (LPCTSTR str) const { return (Compare(str) > 0); };
int main(int argc, char *argv[]) { const char *name = "PATH"; char out_delim = PATHDELIM; int remove_duplicates = FALSE; size_t length = (size_t) argc; int operation = 'a'; const char *where = 0; int c, point = 0; LIST *list; char *s; while ((c = getopt(argc, argv, "a:bdefn:prv")) != EOF) { switch (c) { case 'a': where = optarg; break; case 'b': where = BLANK; break; case 'd': remove_duplicates = TRUE; break; case 'e': where = 0; break; case 'f': allow_files = TRUE; break; case 'n': name = optarg; break; case 'p': out_delim = ' '; break; case 'r': if (where == 0) where = BLANK; operation = c; break; case 'v': out_delim = '\n'; break; default: usage(); } } /* Get the current path, make a corresponding list of strings. Leave * enough room in the list to allow us to insert the arguments also. */ if ((s = getenv(name)) == 0) s = StrAlloc(BLANK); else s = StrAlloc(s); /* ...just in case someone else uses it */ for (c = 0; s[c] != EOS; c++) if (s[c] == PATHDELIM) length++; length += 3; list = (LIST *) calloc(length, sizeof(LIST)); list[0].nn = StrAlloc(BLANK); /* dummy entry, to simplify -b option */ /* Split the environment variable into strings indexed in list[] */ for (c = 1; *s != EOS; c++) { if (*s == PATHDELIM) { list[c].nn = StrAlloc("."); } else { list[c].nn = s; while (*s != PATHDELIM && *s != EOS) s++; if (*s == EOS) continue; *s = EOS; } s++; } list[c].nn = 0; TRACE((stderr, "%s has %d entries\n", name, c)); /* Find the list-entry after which we insert/remove entries */ for (c = 0; list[c].nn != 0; c++) { if (where != 0 && !Compare(where, list[c].nn)) { point = c; break; } } if (list[c].nn == 0) point = c - 1; TRACE((stderr, "argc=%d, point=%d (%c)\n", argc, point, operation)); /* Perform the actual insertion/removal */ while (optind < argc) { s = argv[optind++]; if (!Compare(s, "-")) break; if (operation == 'r') { Remove(point, list, s); } else { point = Append(point, list, s); } } if (remove_duplicates) { /* Check to see if the directory exists. If not, remove it */ for (c = 1; list[c].nn != 0; c++) if (!exists(&list[c])) { Remove(c, list, list[c].nn); c--; }; /* Compare the inode & device numbers of the remaining items */ for (c = 1; list[c].nn != 0; c++) { int d; for (d = c + 1; list[d].nn != 0; d++) { if (SameDir(&list[c], &list[d])) { Remove(d, list, list[d].nn); d--; } } } } /* Finally, print the path */ if (optind < argc) { size_t len = strlen(name) + 2; char *changed = 0; for (c = 1; list[c].nn != 0; c++) len += 1 + strlen(list[c].nn); changed = malloc(len); strcpy(changed, name); for (c = 1; list[c].nn != 0; c++) { sprintf(changed + strlen(changed), "%c%s", (c > 1) ? PATHDELIM : '=', list[c].nn); } fflush(stderr); fflush(stdout); putenv(changed); #ifdef WIN32 spawnvp(_P_WAIT, argv[optind], &argv[optind]); #else execvp(argv[optind], &argv[optind]); #endif fflush(stderr); fflush(stdout); } else { fflush(stderr); for (c = 1; list[c].nn != 0; c++) { if (c > 1) (void) putchar(out_delim); (void) fputs(list[c].nn, stdout); } (void) putchar('\n'); fflush(stdout); } exit(EXIT_SUCCESS); /*NOTREACHED */ }
bool Word::operator==(const Word &compare) const { int ret = Compare(compare); return ret == 0; }
bool dt_RunDrawTest(const char* from, Int_t mode = 0, Int_t verboseLevel = 0) { // This launch a test a TTree::Draw. // The mode currently available are: // 0: Do not load the shared library // 1: Load the shared library before opening the file // 2: Load the shared library after opening the file // 3: Simple TChain test with shared library // 4: Simple Friend test with shared library // The verboseLeve currently available: // 0: As silent as possible, only report errors and overall speed results. // 1: Output 0 + label for the start of each phase // 2: Output 1 + more details on the different phase being done // 3: Output 2 + stop at the first and draw a canvas showing the differences //gDebug = 5; SetVerboseLevel(verboseLevel); if (mode == 1) { if (!TClassTable::GetDict("Event")) { gSystem->Load("Event_cxx"); } gHasLibrary = kTRUE; } TFile *hfile = 0; TTree *tree = 0; if (mode <3) { hfile = new TFile(from); tree = (TTree*)hfile->Get("T"); } if (mode >= 2 && mode <= 4) { if (!TClassTable::GetDict("Event")) { gSystem->Load("Event_cxx"); } else { cerr << "Since libEvent.so has already been loaded, mode 2 can not be tested!"; cerr << endl; } gHasLibrary = kTRUE; } if (mode == 3) { // Test Chains. TChain * chain = new TChain("T"); chain->Add(from); chain->Add(from); tree = chain; } if (mode == 4) { // Test friends. tree = new TTree("T","Base of friendship"); tree->AddFriend("T",from); } TBranch *eb = tree->GetBranch("event"); gBranchStyle = (int) eb->InheritsFrom(TBranchElement::Class()); // cerr << "Branch style is " << gBranchStyle << endl; if (gQuietLevel<2) cout << "Generating histograms from TTree::Draw" << endl; TDirectory* where = GenerateDrawHist(tree,2,gQuietLevel); if (gQuietLevel<2) cout << "Comparing histograms" << endl; if (Compare(where)>0) { cout << "DrawTest: Comparison failed" << endl; return false; } DrawMarks(); if (gQuietLevel<2) cout << "DrawTest: Comparison was successfull" << endl; if (hfile) delete hfile; else delete tree; gROOT->GetList()->Delete(); return true; }
int WebRect::Split(WebRect *pRect1, WebRect *pRect2) { return (SplitCase(pRect1, pRect2, Compare(pRect1))); }
void PlanPrep::File_Merge (void) { int next_in, next_in_trip, next_merge, next_merge_trip, last_in, last_merge, replace_id, replace_trip, current_in; bool read_merge, read_in, save_merge, save_in, skip; Plan_Data *input_ptr, *merge_ptr; Plan_File temp_plan; if (input_plans.Extend ()) { Show_Message ("Merging Plan Files %s -- Plan", input_plans.Extension ()); } else { Show_Message ("Merging Plan Files -- Plan"); } last_in = last_merge = replace_id = replace_trip = current_in = 0; read_merge = read_in = save_merge = save_in = skip = false; Set_Progress (10000); //---- read the first record in the input file ---- for (;;) { if (input_plans.Read ()) { input_ptr = input_plans.Plan (); if (one_leg_flag && input_ptr->leg == 1) { if (temp_plan.Leg () == 1) num_one_leg++; temp_plan.Plan (input_ptr); continue; } next_in = input_ptr->key1; next_in_trip = input_ptr->trip; } else { next_in = MAX_INTEGER; } break; } //---- read the first record in the merge file ---- if (merge_plans.Read ()) { merge_ptr = merge_plans.Plan (); next_merge = merge_ptr->key1; next_merge_trip = merge_ptr->trip; } else { next_merge = MAX_INTEGER; } //---- interleaf plan records based on traveler ID ---- for (;;) { if (next_in == MAX_INTEGER && next_merge == MAX_INTEGER) break; Show_Progress (); //---- set the processing flags ---- if (next_merge < next_in) { if (next_merge == replace_id && (!trip_flag || next_merge_trip == replace_trip)) { save_merge = false; } else { save_merge = true; } read_merge = true; read_in = save_in = false; } else { //---- check the time period criteria ---- if (time_flag) { skip = (time_period.In_Range (input_plans.Time ()) == 0); } if (hhold_flag) { skip = (hhold_range.In_Range (input_plans.Traveler ()) == 0); } if (delete_flag) { skip = (delete_list.Get_Index (input_plans.Household ()) != 0); } if (!skip && select_flag) { if (current_in != next_in) { current_in = next_in; skip = (random.Probability () >= percent); } } if (skip) { save_in = read_merge = save_merge = false; read_in = true; } else if (next_merge == next_in) { if (trip_flag) { if (next_merge_trip < next_in_trip) { read_merge = save_merge = true; read_in = save_in = false; } else if (next_merge_trip == next_in_trip) { if (replace_id != next_in) { replaced++; replace_id = next_in; } replace_trip = next_in_trip; if (compare_flag) { Compare (input_ptr, merge_ptr); } read_merge = read_in = save_in = true; save_merge = false; } else { read_in = save_in = true; read_merge = save_merge = false; } } else { if (replace_id != next_in) { replaced++; replace_id = next_in; replace_trip = next_in_trip; } if (compare_flag) { Compare (input_ptr, merge_ptr); } read_merge = read_in = save_in = true; save_merge = false; } } else { read_in = save_in = true; read_merge = save_merge = false; } } //---- write the merge plan to the output file ---- if (save_merge) { if (next_merge < last_merge) { Error ("The Merge Plan File is Not Sorted by %s", ((sort == TIME_SORT) ? "Time" : "Traveler")); } last_merge = next_merge; Output_Plan (merge_ptr); } //---- get the next merge plan ---- if (read_merge) { if (merge_plans.Read ()) { merge_ptr = merge_plans.Plan (); next_merge = merge_ptr->key1; next_merge_trip = merge_ptr->trip; } else { next_merge = MAX_INTEGER; } } //---- write the input plan in the output file ---- if (save_in) { if (next_in < last_in) { Error ("The Input Plan File is Not Sorted by %s", ((sort == TIME_SORT) ? "Time" : "Traveler")); } last_in = next_in; if (fix_flag) { input_ptr = Fix_Plan (input_ptr); } if (one_leg_flag && input_ptr->leg == 2) { Output_Plan (temp_plan.Plan ()); temp_plan.Leg (0); } Output_Plan (input_ptr); } //---- get the next input plan ---- if (read_in) { for (;;) { if (input_plans.Read ()) { input_ptr = input_plans.Plan (); if (one_leg_flag && input_ptr->leg == 1) { if (temp_plan.Leg () == 1) num_one_leg++; temp_plan.Plan (input_ptr); continue; } next_in = input_ptr->key1; next_in_trip = input_ptr->trip; } else { next_in = MAX_INTEGER; } break; } } } End_Progress (); input_plans.Close (); merge_plans.Close (); output_plans.Close (); }
inline bool operator==(const ValueObject& other) const { return Compare(other) == 0; }
// //----------------------------------------------------------------------------- // function : spin_sort /// @brief constructor of the struct /// @param [in] r_input : range of elements to sort /// @param [in] comp : object for to Compare two elements //----------------------------------------------------------------------------- spin_sort ( Iter_t first , Iter_t last , Compare comp = Compare()): spin_sort ( first, last, comp, nullptr, 0 ) { } ;
int main( int argc, char **argv ) { //printf("%d", LevenshteinDistance("*****@*****.**", "xiaoxia yquoxitsoftwareLom")); //return 1; ParseParam ArgvParser = ParseParam(argc, argv); if (argc == 1) { ArgvParser.HelpInfo(); return 1; } ArgvParser.SetGetOptStr("r::g::c::f::w:n:m:p:e:i:t:o:a:sh"); int arg_index = 0; while(1) { int c = ArgvParser.CallGetOpt(); ArgvParser.ParseVal(c, arg_index); arg_index++; if(c == -1) break; } //TextProcess tt; //tt.Test1(); ArgValues InVal = ArgvParser.GetResult(); vector<string> VPValW; vector<int> VPValN; IplImage* pImgGet0 = NULL; IplImage* pImgGet1 = NULL; for (int i = 0; i < InVal.ActionFlag.size(); i++) { switch (InVal.ActionFlag[i]) { case FXQA_FUNC_COMPAREIMG: _DEBUG_INFO("COMPAREIMG run.\n"); if (strcmp(InVal.ImgName0, "-c") == 0) { // compare images. _DEBUG_INFO("-c runned.\n"); if (strcmp(InVal.ImgName1, "-w") == 0) { _DEBUG_INFO("-w runned.\n"); Compare(pImgGet0, pImgGet1, InVal); break; // Compare images. all from srceen shot. } else { Compare(pImgGet0, InVal); break; // Compare images. one from srceen shot,other is local file. } } Compare(InVal); break; // Compare images, or file. case FXQA_FUNC_GETDESKTOPIMG: _DEBUG_INFO("GETDESKTOPIMG run.\n"); VPValW = ArgvParser.ParseInputWValue(InVal.ProgramVal); VPValN = ArgvParser.ParseInputNValue(InVal.ScreenShotSize); if (VPValW.size() == 0) { pImgGet0 = GetScreenImg(argc, argv, NULL, InVal); } else if (VPValW.size() == 1) { pImgGet0 = GetScreenImg(argc, argv, VPValW[0].c_str(), InVal); } else { pImgGet0 = GetScreenImg(argc, argv, VPValW[0].c_str(), InVal); pImgGet1 = GetScreenImg(argc, argv, VPValW[1].c_str(), InVal); } break; case FXQA_FUNC_COMPOSE: Compose(InVal); break; case FXQA_FUNC_FINDIMG: FXQAFunc_Find(argc, argv, InVal); break; case FXQA_FUNC_OCR: FXQAFunc_OCR(argc, argv, InVal); break; default: _DEBUG_INFO("DEFAULT run.\n"); break; } } return 0; }
TST_tpRetCode TST_TestSpecific :: PerformSpecificTest( char * Command ) { // Interpret TCFG Reset // AE: Reset if ( strcmp( Command , Reset_CMD ) == 0 ) { for ( int i = 0 ; i < TCFG_dimVtObj ; i++ ) { delete vtObj[ i ] ; vtObj[ i ] = NULL ; } /* for */ return TST_RetCodeOK ; } // end selection: Interpret TCFG Reset // Test: CFG !Construct a configuration list // AE: NewParamList <inxObj> else if ( strcmp( Command , CFG_CParameterList_002_CMD ) == 0 ) { /***** Function CFG_ConfigurationList( ) *****/ int inxObj = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxObj ) ; if ( ( numRead != 1 ) || !VerifyInxElem( inxObj , NO )) { return TST_RetCodeParmError ; } /* if */ vtObj[ inxObj ] = new CFG_ConfigurationList( ) ; return TST_RetCodeOK ; } // end selection: Test: CFG !Construct a configuration list // Test: CFG !Destroy a parameter list // AE: DeleteParamList <inxObj> else if ( strcmp( Command , DeleteCFG_CParameterList_003_CMD ) == 0 ) { /***** Function ~CFG_ConfigurationList( ) *****/ int inxObj = -1 ; int numRead = TST_pReader->ReadCommandLine( "i" , &inxObj ) ; if ( ( numRead != 1 ) || !VerifyInxElem( inxObj , ANY )) { return TST_RetCodeParmError ; } /* if */ delete vtObj[ inxObj ] ; vtObj[ inxObj ] = NULL ; return TST_RetCodeOK ; } // end selection: Test: CFG !Destroy a parameter list // Test: CFG !Build from given file // AE: BuildList <inxObj> <s EnvName> <s FileName> <s ExtensionName> <b expReturn> // EnvName == "." ==> NULL reads the file identified // by the "TALISMAN" environment variable // FileName == "." ==> NULL reads the file identified // by the environment variable // ExtName == "." ==> NULL uses "config" as deafult extension // name else if ( strcmp( Command , BuildLineList_006_CMD ) == 0 ) { /***** Function bool BuildLineList( char * FileName , char * FileExtension ) *****/ int inxObj = -1 ; bool expRet = false ; int sizFileName = -1 ; char FileName[ TAL_dimBuffer ] ; int sizExtName = -1 ; char ExtName[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "issb" , &inxObj , &sizFileName , FileName , &sizExtName , ExtName , &expRet ) ; if ( ( numRead != 4 ) || !VerifyInxElem( inxObj , YES )) { return TST_RetCodeParmError ; } /* if */ return CompareBool( vtObj[ inxObj ]->BuildLineList( ( strcmp( FileName , "." ) != 0 ? FileName : NULL ) , ( strcmp( ExtName , "." ) != 0 ? ExtName : NULL )) , expRet , "Incorrect configuration build return." ) ; } // end selection: Test: CFG !Build from given file // Test: CFG !Write configuration file // AE: WriteList <inxObj> <s FileNmae> <s ExtensionName> <b expReturn> // FileName == "." ==> NULL // ExtName == "." ==> NULL else if ( strcmp( Command , WriteConfigurationList_006_CMD ) == 0 ) { /***** Function bool WriteConfigurationList( char * FileName , char * ExtensionName = NULL ) *****/ int inxObj = -1 ; bool expRet = false ; int sizFileName = -1 ; char FileName[ TAL_dimBuffer ] ; int sizExtName = -1 ; char ExtName[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "issb" , &inxObj , &sizFileName , FileName , &sizExtName , ExtName , &expRet ) ; if ( ( numRead != 4 ) || !VerifyInxElem( inxObj , YES )) { return TST_RetCodeParmError ; } /* if */ return CompareBool( vtObj[ inxObj ]->WriteConfigurationList( ( strcmp( FileName , "." ) != 0 ? FileName : NULL ) , ( strcmp( ExtName , "." ) != 0 ? ExtName : NULL )) , expRet , "Incorrect configuration write return." ) ; } // end selection: Test: CFG !Write configuration file // Test: CFG !Get a parameter value // AE: GetParameter <inxObj> <s SectionName> <s ParameterName> <s expValue> else if ( strcmp( Command , GetParameter_007_CMD ) == 0 ) { /***** Function STR_String * GetParameterValue( char * SectionName , char * AttributeName ) *****/ int inxObj = -1 ; int sizSecName = -1 ; char SecName[ TAL_dimBuffer ] ; int sizParmName = -1 ; char ParmName[ TAL_dimBuffer ] ; int sizexpValue = -1 ; char expValue[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "isss" , &inxObj , &sizSecName , SecName , &sizParmName , ParmName , &sizexpValue , expValue ) ; if ( ( numRead != 4 ) || !VerifyInxElem( inxObj , YES )) { return TST_RetCodeParmError ; } /* if */ STR_String * pStr = vtObj[ inxObj ]->GetParameterValue( SecName , ParmName ) ; if ( pStr == NULL ) { if ( strcmp( expValue , "." ) == 0 ) { return TST_RetCodeOK ; } /* if */ DisplayErrorMsg( "Expected parameter has not been found." ) ; return TST_RetCodeFailure ; } /* if */ TST_tpRetCode retCode = Compare( pStr->GetString( ) , expValue , sizexpValue , "Incorrect parameter value." ) ; delete pStr ; return retCode ; } // end selection: Test: CFG !Get a parameter value // Test: CFG !Set a parameter value // AE: SetParameter <inxObj> <s SectionName> <s ParameterName> <s newValue> <b expRet> else if ( strcmp( Command , SetParameter_013_CMD ) == 0 ) { /***** Function bool SetParameterValue( char * SectionName , char * ParameterName , STR_String * ParameterValue ) *****/ int inxObj = -1 ; bool expRet = false ; int sizSecName = -1 ; char SecName[ TAL_dimBuffer ] ; int sizParmName = -1 ; char ParmName[ TAL_dimBuffer ] ; int sizValue = -1 ; char Value[ TAL_dimBuffer ] ; int numRead = TST_pReader->ReadCommandLine( "isssb" , &inxObj , &sizSecName , SecName , &sizParmName , ParmName , &sizValue , Value , &expRet ) ; if ( ( numRead != 5 ) || !VerifyInxElem( inxObj , YES )) { return TST_RetCodeParmError ; } /* if */ STR_String * pVal = new STR_String( sizValue , Value ) ; bool isRet = vtObj[ inxObj ]->SetParameterValue( SecName , ParmName , pVal ) ; return CompareBool( isRet , expRet , "Incorrect set parameter return." ); } // end selection: Test: CFG !Set a parameter value // Perform compare file // AE: CompareFile <s FileA> <s extFileA> <s FileB> <s extFileB> <b expRet> else if ( strcmp( Command , CompareFile_CMD ) == 0 ) { int lenFileA = -1 ; char fileA[ TAL_dimBuffer ] ; int lenExtA = -1 ; char ExtA[ TAL_dimBuffer ] ; int lenFileB = -1 ; char fileB[ TAL_dimBuffer ] ; int lenExtB = -1 ; char ExtB[ TAL_dimBuffer ] ; bool expBool = false ; int numRead = TST_pReader->ReadCommandLine( "ssssb" , &lenFileA , fileA , &lenExtA , ExtA , &lenFileB , fileB , &lenExtB , ExtB , &expBool ) ; if ( numRead != 5 ) { return TST_RetCodeParmError ; } /* if */ return CompareBool( SIO_CompareFile( fileA , ExtA , fileB , ExtB ) , expBool , "Incorrect comparison." ) ; } // end selection: Perform compare file // Test: CFGE !Configuration element constructor // AE: CFGE_LineListElem_002_CMD else if ( strcmp( Command , CFGE_CLineListElem_002_CMD ) == 0 ) { /***** Function CFGE_LineListElem( ) *****/ return TST_RetCodeNotImplemented ; } // end selection: Test: CFGE !Configuration element constructor // Test: CFGE !Configuration element destructor // AE: DeleteCFGE_LineListElem_003_CMD else if ( strcmp( Command , DeleteCFGE_CLineListElem_003_CMD ) == 0 ) { /***** Function ~CFGE_LineListElem( ) *****/ return TST_RetCodeNotImplemented ; } // end selection: Test: CFGE !Configuration element destructor // Test var: Line type // AE: LineType_006 else if ( strcmp( Command , LineType_006 ) == 0 ) { /***** Variable tpLineType LineType ; *****/ return TST_RetCodeNotImplemented ; } // end selection: Test var: Line type // Test var: Next section element // AE: proxSection_007 else if ( strcmp( Command , proxSection_007 ) == 0 ) { /***** Variable CFG_ParamenterListElement * proxSection ; *****/ return TST_RetCodeNotImplemented ; } // end selection: Test var: Next section element // Test var: Next atribute element // AE: proxAttribute_008 else if ( strcmp( Command , proxAttribute_008 ) == 0 ) { /***** Variable CFG_ParamenterListElement * proxAttribute ; *****/ return TST_RetCodeNotImplemented ; } // end selection: Test var: Next atribute element // Test var: Element name // AE: pElementName_009 else if ( strcmp( Command , pElementName_009 ) == 0 ) { /***** Variable STR_String * pElementName ; *****/ return TST_RetCodeNotImplemented ; } // end selection: Test var: Element name // Test var: Element value // AE: pElementValue_021 else if ( strcmp( Command , pElementValue_021 ) == 0 ) { /***** Variable STR_String * pElementValue ; *****/ return TST_RetCodeNotImplemented ; } // end selection: Test var: Element value return TST_RetCodeUnknown ; } // End of function: TCFG !P Perform specific test actions
BOOL CDictionary::FindSlot (int iKey, int *retiPos) const // FindSlot // // Returns the position in the array for the given key. If // the key was not found, retiPos is the position at which the // key should be inserted. Return TRUE if the key is found, // FALSE otherwise. { int iLeft, iRight, iCount; int iEntryKey, iCompare; // If there are no entries, then we always fail iCount = GetCount(); if (iCount == 0) { *retiPos = 0; return FALSE; } // Do a binary search looking for the key iLeft = 0; iRight = iCount - 1; while (iRight > iLeft) { int iTry; // Pick a point in between our two extremes iTry = iLeft + (iRight - iLeft) / 2; // Get the key at that point. Remember that // we store the key and the value in a single array, so // we need to multiply by two. iEntryKey = m_Array.GetElement(iTry * 2); // Figure out if we've matched the key iCompare = Compare(iEntryKey, iKey); if (iCompare == 0) { *retiPos = iTry * 2; return TRUE; } else if (iCompare == 1) iRight = iTry - 1; else iLeft = iTry + 1; } // If we could not find the key, compute the insertion // position iEntryKey = m_Array.GetElement(iLeft * 2); iCompare = Compare(iEntryKey, iKey); if (iCompare == 0) { *retiPos = iLeft * 2; return TRUE; } else if (iCompare == 1) *retiPos = iLeft * 2; else *retiPos = (iLeft + 1) * 2; return FALSE; }
bool operator() (const std::pair<K, V>& x, const std::pair<K, V>& y) const { return Compare()(x.first, y.first); }
nsresult nsAbLDAPProcessChangeLogData::ParseChangeLogEntries(nsILDAPMessage *aMessage) { NS_ENSURE_ARG_POINTER(aMessage); if(!mInitialized) return NS_ERROR_NOT_INITIALIZED; // Populate the RootDSEChangeLogEntry CharPtrArrayGuard attrs; nsresult rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr()); // No attributes if(NS_FAILED(rv)) return rv; nsAutoString targetDN; UpdateOp operation = NO_OP; for(int32_t i = attrs.GetSize()-1; i >= 0; i--) { PRUnicharPtrArrayGuard vals; rv = aMessage->GetValues(attrs.GetArray()[i], vals.GetSizeAddr(), vals.GetArrayAddr()); if(NS_FAILED(rv)) continue; if(vals.GetSize()) { if (!PL_strcasecmp(attrs[i], "targetdn")) targetDN = vals[0]; if (!PL_strcasecmp(attrs[i], "changetype")) { if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("add"), nsCaseInsensitiveStringComparator())) operation = ENTRY_ADD; if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("modify"), nsCaseInsensitiveStringComparator())) operation = ENTRY_MODIFY; if (!Compare(nsDependentString(vals[0]), NS_LITERAL_STRING("delete"), nsCaseInsensitiveStringComparator())) operation = ENTRY_DELETE; } } } mChangeLogEntriesCount++; if(!(mChangeLogEntriesCount % 10)) { // Inform the listener every 10 entries mListener->OnProgressChange(nullptr,nullptr,mChangeLogEntriesCount, -1, mChangeLogEntriesCount, -1); // In case if the LDAP Connection thread is starved and causes problem // uncomment this one and try. // PR_Sleep(PR_INTERVAL_NO_WAIT); // give others a chance } #ifdef DEBUG_rdayal printf ("ChangeLog Replication : Updated Entry : %s for OpType : %u\n", NS_ConvertUTF16toUTF8(targetDN).get(), operation); #endif switch(operation) { case ENTRY_ADD: // Add the DN to the add list if not already in the list if(!(mEntriesToAdd.IndexOf(targetDN) >= 0)) mEntriesToAdd.AppendString(targetDN); break; case ENTRY_DELETE: // Do not check the return here since delete may fail if // entry deleted in changelog does not exist in DB // for e.g if the user specifies a filter, so go next entry DeleteCard(targetDN); break; case ENTRY_MODIFY: // For modify, delete the entry from DB and add updated entry // we do this since we cannot access the changes attribs of changelog rv = DeleteCard(targetDN); if (NS_SUCCEEDED(rv)) if(!(mEntriesToAdd.IndexOf(targetDN) >= 0)) mEntriesToAdd.AppendString(targetDN); break; default: // Should not come here, would come here only // if the entry is not a changeLog entry NS_WARNING("nsAbLDAPProcessChangeLogData::ParseChangeLogEntries" "Not an changelog entry"); } // Go ahead processing the next entry, a modify or delete DB operation // can 'correctly' fail if the entry is not present in the DB, // e.g. in case a filter is specified. return NS_OK; }
int IfaceCheckApp::OnRun() { long startTime = wxGetLocalTime(); // for timing purpose wxCmdLineParser parser(g_cmdLineDesc, argc, argv); parser.SetLogo( wxString::Format("wxWidgets Interface checker utility (built %s against %s)", __DATE__, wxVERSION_STRING)); // make the output more readable: wxLog::SetActiveTarget(new IfaceCheckLog); wxLog::DisableTimestamp(); // parse the command line... bool ok = true; wxString preprocFile; switch (parser.Parse()) { case 0: if (parser.Found(VERBOSE_SWITCH)) g_verbose = true; // IMPORTANT: parsing #define values must be done _before_ actually // parsing the GCC/doxygen XML files if (parser.Found(USE_PREPROCESSOR_OPTION, &preprocFile)) { if (!ParsePreprocessorOutput(preprocFile)) return 1; } // in any case set basic std preprocessor #defines: m_doxyInterface.AddPreprocessorValue("NULL", "0"); // parse the two XML files which contain the real and the doxygen interfaces // for wxWidgets API: if (!m_gccInterface.Parse(parser.GetParam(0)) || !m_doxyInterface.Parse(parser.GetParam(1))) return 1; if (parser.Found(DUMP_SWITCH)) { wxLogMessage("Dumping real API to '%s'...", API_DUMP_FILE); m_gccInterface.Dump(API_DUMP_FILE); wxLogMessage("Dumping interface API to '%s'...", INTERFACE_DUMP_FILE); m_doxyInterface.Dump(INTERFACE_DUMP_FILE); } else { if (parser.Found(MODIFY_SWITCH)) m_modify = true; if (parser.Found(PROCESS_ONLY_OPTION, &m_strToMatch)) { size_t len = m_strToMatch.Len(); if (m_strToMatch.StartsWith("\"") && m_strToMatch.EndsWith("\"") && len > 2) m_strToMatch = m_strToMatch.Mid(1, len-2); } ok = Compare(); } PrintStatistics(wxGetLocalTime() - startTime); return ok ? 0 : 1; default: wxPrintf("\nThis utility checks that the interface XML files created by Doxygen are in\n"); wxPrintf("synch with the real headers (whose contents are extracted by the gcc XML file).\n\n"); wxPrintf("The 'gccXML' parameter should be the wxapi.xml file created by the 'rungccxml.sh'\n"); wxPrintf("script which resides in 'utils/ifacecheck'.\n"); wxPrintf("The 'doxygenXML' parameter should be the index.xml file created by Doxygen\n"); wxPrintf("for the wxWidgets 'interface' folder.\n\n"); wxPrintf("Since the gcc XML file does not contain info about #defines, if you use\n"); wxPrintf("the -%s option, you'll get a smaller number of false warnings.\n", USE_PREPROCESSOR_OPTION); // HELP_SWITCH was passed or a syntax error occurred return 0; } }
explicit ptr_multimap( const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( comp, a ) { }
inline indirect_cmp(const ReadablePropertyMap& df, const Compare& c = Compare()) : d(df), cmp(c) { }
ptr_multimap( InputIterator first, InputIterator last, const Compare& comp = Compare(), const Allocator& a = Allocator() ) : base_type( first, last, comp, a ) { }
avlbfl_multiset(InputIterator aFirst, InputIterator aLast, const Compare& comp = Compare(), const allocator_type& = allocator_type()) : base_impl_type(aFirst, aLast, comp) { };
// // Method name : operator< // Description : Returns true if this method signature does not match the // argument and the hash value for this signature is lower than the other. // bool CJavaMethodSignature::operator<(const CJavaMethodSignature& other) const { return Compare(other) > 0; }