// // Generates and displays a two-column list of choices for the use // to choose from. The return value is the string the user has chosen. // static string getSettingByList( const RaceAnalyzer::StrSet &data, const char *prompt ) { cout << endl; // // Determine how many rows there will be in the 2-column display // size_t numRows = ( data.size() / 2 ) + ( data.size() % 2 ); // // Generate the container of row/string data // ColumnData columnData = buildColumnData(data, numRows); // // Display the multi-column choice list. // RaceAnalyzer::StrSet::const_iterator midIter = data.begin(); advance( midIter, numRows-1 ); for_each( columnData.begin(), columnData.end(), DisplayChoice(numRows, *midIter) ); if (data.size() % 2) cout << endl; // // Get (and validate) the user's choice // unsigned num; while(true) { string numStr = getSetting(prompt); if ( ! numStr.size() ) // blank indicates "all" return numStr; num = atoi( numStr.c_str() ); if ( num >= 1 && num <= data.size() ) break; cout << endl << " *** Invalid number. Try Again. ***" << endl; } // // Return the chosen string from the user's numeric input. // RaceAnalyzer::StrSet::const_iterator iter = data.begin(); advance( iter, num-1 ); return *iter; }
Bool_t IsBlacklisted(Int_t index, ColumnData& blacklist) { Double_t val = index; return std::binary_search(blacklist.begin(), blacklist.end(), val); }