int PyView::setItem(int i, PyObject* v) { if (PyGenericRowRef_Check(v)) return setItemRow(i, *(PyRowRef *)v); c4_Row temp; makeRow(temp, v, false); return setItemRow(i, temp); }
Row *RowType::copyRow(const RowType *rtype, const Row *row) const { FdataVec v; rtype->splitInto(row, v); if (v.size() > fields_.size()) v.resize(fields_.size()); // truncate if too long return makeRow(v); }
void UserList::userChanged(User const & user) { try { updateRow(makeRow(user)); // throws if row not found } catch (std::runtime_error & e) { // ignore } }
//This function checks orientation and call the appropriate method Wall::Wall(int index, int orientation) { placeholder = false; if(orientation == 0) { makeRow(index); } else { makeColumn(index); } }
PackedConstraints packConstraints() const { PackedConstraints retval; typedef detail::constraint::Vector::const_iterator CIter; for ( CIter i = constraints.begin(); i != constraints.end(); ++i ) { retval.lower.push_back( i->lower ); retval.upper.push_back( i->upper ); retval.m.addRow( makeRow( parameters, i->factors ) ); } assert( retval.lower.size() == retval.upper.size() && static_cast<int>(retval.lower.size()) == retval.m.getNrows()&& static_cast<int>(parameters.size()) == retval.m.getNcols()); return retval; }
//---------------------------------------------------------------------- void CondProbTableTest::RunTests() { // Our 4 rows vector<vector<Real> > rows; rows.resize(numRows()); rows[0] = makeRow((Real)0.0, (Real)0.4, (Real)0.0); rows[1] = makeRow((Real)1.0, (Real)0.0, (Real)0.0); rows[2] = makeRow((Real)0.0, (Real)0.0, (Real)0.6); rows[3] = makeRow((Real)0.0, (Real)0.6, (Real)0.4); // Test constructing without # of columns { CondProbTable table; // Add the 4 rows for (Size i=0; i<numRows(); i++) table.updateRow((UInt)i, rows[i]); // Test it testTable ("Dynamic columns:", table, rows); } // Test constructing and growing the columns dynamically { CondProbTable table; // Add the 2nd row first which has just 1 column vector<Real> row1(1); row1[0] = rows[1][0]; table.updateRow(1, row1); // Add the first row first with just 2 columns vector<Real> row0(2); row0[0] = rows[0][0]; row0[1] = rows[0][1]; table.updateRow(0, row0); for (Size i=2; i<numRows(); i++) table.updateRow((UInt)i, rows[i]); // Test it testTable ("Growing columns:", table, rows); } // Make a table with 3 columns { CondProbTable table((UInt)numCols()); // Add the 4 rows for (Size i=0; i<numRows(); i++) table.updateRow((UInt)i, rows[i]); // Test it testTable ("Fixed columns:", table, rows); } // Make a table, save to stream, then reload and test { CondProbTable table((UInt)numCols()); // Add the 4 rows for (Size i=0; i<numRows(); i++) table.updateRow((UInt)i, rows[i]); // Save it stringstream state; table.saveState (state); CondProbTable newTable; newTable.readState (state); testTable ("Restored from state:", newTable, rows); } // Test saving an empty table { CondProbTable table; // Save it stringstream state; table.saveState (state); // Read it in CondProbTable newTable; newTable.readState (state); // Add the 4 rows for (Size i=0; i<numRows(); i++) newTable.updateRow((UInt)i, rows[i]); // Test it testTable ("Restored from empty state:", newTable, rows); } }
/** * Read in paramaters and output a maze line by line. */ int main(int argc, char *argv[]) { // read in paramaters if (argc < 3) { fprintf(stderr, "Usage: %s [width] [height] [OPTIONS]\n", argv[0]); fprintf(stderr, "\ta - ASCII style maze (default).\n"); fprintf(stderr, "\tb - BLOCK style maze.\n"); fprintf(stderr, "\tds - Turn set debug on.\n"); fprintf(stderr, "\tdr - Turn row debug on.\n"); fprintf(stderr, "\tr - Turn off random generation.\n"); return 1; } // Read in required args width = atoi(argv[1]); uint height = atoi(argv[2]); // Check to make sure they are valid if (width == 0 || height == 0) { fprintf(stderr, "Maze width and height must be greater then 0.\n"); return 1; } MAZETYPE type = ASCII; debugsets = false; srand(time(NULL)); // Read in optional args for (int i = 2; i < argc; i++) { if (0 == strcmp(argv[i], "ds")) debugsets = true; if (0 == strcmp(argv[i], "dr")) debugrows = true; // "Turn off" randomness if (0 == strcmp(argv[i], "r")) srand(1); if (0 == strcmp(argv[i], "a")) type = ASCII; if (0 == strcmp(argv[i], "b")) type = BLOCK; } // Create/init vars set = new uint[width]; row = new uint[width]; previousRow = new uint[width]; for (uint i = 0; i < width; i++) { set[i] = i + width + 1; row[i] = 0; previousRow[i] = 0; } // create & print out the rows bool isLast, isFirst; for (uint i = 0; i < height; i++) { isLast = (i == height - 1); isFirst = (i == 0); makeRow(isLast); if (type == ASCII) outputASCII(isLast, isFirst); else if (type == BLOCK) outputBlock(isLast); } // Memory cleanup; delete[]set; delete[]row; delete[]previousRow; return 0; }
void PyView::insertAt(int i, PyObject* o) { c4_Row temp; makeRow(temp, o); InsertAt(i, temp); }
void UserList::add(User const & user) { addRow(makeRow(user)); }