void PrettyPrinter::special_print(const Store* store, std::ostream& outStream, const std::string tableName, const size_t& limit, const size_t& start) { ftprinter::FTPrinter tp(tableName, outStream); tp.addColumn("#rowid", 6); const size_t columns = store->columnCount(); // TODO: how about using limit=0 as parameter to print whole table instead of strange -1 for unsigned? auto prepareLimit = (limit < (size_t) - 1) ? std::min(limit, store->size()) : store->size(); for (size_t column_index = 0; column_index < columns; ++column_index) { // Auto adjusting widths means iterating over the table twice, but we use it for // debugging purposes only, anyways, so we'll go with beauty of output here auto name = store->nameOfColumn(column_index); size_t width = std::accumulate(RangeIter(0), RangeIter(prepareLimit), // minimum width is 4 name.size() > 4 ? name.size() : 4, [&](size_t max, const size_t row)->size_t { size_t sz = generateValue(store, column_index, row).size(); return sz > max ? sz : max; }); tp.addColumn(name, width); } tp.addColumn("$tid", 6); tp.addColumn("$cidbeg", 6); tp.addColumn("$cidend", 6); if (limit < (size_t) - 1) { outStream << "(showing first " << limit << " rows)" << std::endl; } if (tableName.size() > 0) tp.printTableName(); tp.printHeader(); for (size_t row = start; row < store->size() && row < limit; ++row) { tp << row; for (size_t column = 0; column < columns; ++column) { tp << generateValue(store, column, row); } writeTid(tp, store->_tidVector[row]); writeCid(tp, store->_cidBeginVector[row]); writeCid(tp, store->_cidEndVector[row]); } tp.printFooter(); }
int main (void) { int arraySize; printf("Enter the array size: "); scanf("%d", &arraySize); int matrix[arraySize][arraySize]; for (int i = 0; i < arraySize; i++) { for (int j = 0; j < arraySize; j++) { matrix[i][j] = generateValue(i, j, matrix); } } for (int i = 0; i < arraySize; i++) { for (int ii = 0; ii < arraySize; ii++) { printf("\t%d", matrix[i][ii]); } printf("\n"); } return 0; }
double Oscillator::tick() { generateValue(); curAngle += angleDelta; if (curAngle > 2.0 * double_Pi) { curAngle -= 2.0 * double_Pi; } return value; }
void PrettyPrinter::special_print(T& input, std::ostream& outStream, const std::string tableName, const size_t& limit, const size_t& start) { ftprinter::FTPrinter tp(tableName, outStream); tp.addColumn("#rowid", 6); auto prepareLimit = (limit < (size_t) - 1) ? std::min(limit, input->size()) : input->size(); const size_t columns = input->columnCount(); for (size_t column_index = 0; column_index < columns; ++column_index) { // Auto adjusting widths means iterating over the table twice, but we use it for // debugging purposes only, anyways, so we'll go with beauty of output here auto name = input->nameOfColumn(column_index); size_t width = std::accumulate(RangeIter(0), RangeIter(prepareLimit), // minimum width is 4 name.size() > 4 ? name.size() : 4, [&](size_t max, const size_t & row)->size_t { size_t sz = generateValue(input, column_index, row).size(); return sz > max ? sz : max; }); tp.addColumn(name, width); } if (limit < (size_t) - 1) { outStream << "(showing first " << limit << " of " << input->size() << " rows)" << std::endl; } if (tableName.size() > 0) tp.printTableName(); tp.printHeader(); for (size_t row = start; row < input->size() && row < limit; ++row) { tp << row; for (size_t column = 0; column < columns; ++column) { tp << generateValue(input, column, row); } } tp.printFooter(); }
int generateP_A(str a){ if(isNumber(a)){ generateValue(a); }else{ int AvarIndex=variableManager.getItemIndex(a); if(AvarIndex==-1){ // jezeli nie istnieje zmienna a AvarIndex=constantManager.getItemIndex(a); if(AvarIndex==-1){ if(ERR)printf("*******ARITH OP NIE ZNALEZIONO"); return -1; }else{ generateValue(constantManager.getItemValue(AvarIndex)); // generuj wartosc stalej } }else{ // jezeli istnieje zmienna char temp[50]; sprintf(temp, "LOAD %d", AvarIndex); addCodeLine(temp); } } return 0; }
void PrettyPrinter::printDiff(const c_atable_ptr_t& input, const TableDiff& diff, std::ostream& outStream, const std::string tableName, const size_t& limit, const size_t& start) { ftprinter::FTPrinter tp(tableName, outStream); tp.addColumn("#rowid", 6); const size_t columns = input->columnCount(); for (size_t column_index = 0; column_index < columns; ++column_index) { // Auto adjusting widths means iterating over the table twice, but we use it for // debugging purposes only, anyways, so we'll go with beauty of output here auto name = input->nameOfColumn(column_index); size_t width = std::accumulate(RangeIter(0), RangeIter(input->size()), // minimum width is 4 name.size() > 4 ? name.size() : 4, [&](size_t max, const size_t & row)->size_t { size_t sz = generateValue(input, column_index, row).size(); return sz > max ? sz : max; }); ftprinter::PrintFormat format = ftprinter::format::basic; if (diff.fields[column_index] == TableDiff::FieldWrong) format = ftprinter::format::red; else if (diff.fields[column_index] == TableDiff::FieldWrongType) format = ftprinter::format::magenta; tp.addColumn(name, width, format); } outStream << std::endl; if (limit < (size_t) - 1) { outStream << "(showing first " << limit << " rows)" << std::endl; } auto iWrong = diff.wrongRows.begin(); auto iFalsePos = diff.falsePositionRows.begin(); while (iWrong != diff.wrongRows.end() && *iWrong < start) iWrong++; while (iFalsePos != diff.falsePositionRows.end() && (*iFalsePos).first < start) iFalsePos++; if (tableName.size() > 0) tp.printTableName(); tp.printHeader(); for (size_t row = start; row < input->size() && row < limit; ++row) { tp << row; if (iWrong != diff.wrongRows.end() && *iWrong == row) { tp << ftprinter::format::red; iWrong++; } if (iFalsePos != diff.falsePositionRows.end() && (*iFalsePos).first == row) { tp << ftprinter::format::yellow; iFalsePos++; } for (field_t column = 0; column < columns; ++column) { tp << generateValue(input, column, row); } } tp.printFooter(); };