static void _update_row( QTableWidget * table,const T& list,int row,const QFont& font ) { _manage_row( table,list,[ & ](){ _for_each_column( table,row,[ & ]( count_t row,count_t col ){ _set_item( table->item( row,col ),_at( list,col ),font ) ; } ) ; } ) ; }
static void _add_row( QTableWidget * table,const T& l,const QFont& font ) { _manage_row( table,l,[ & ](){ count_t row = table->rowCount() ; table->insertRow( row ) ; _for_each_column( table,row,[ & ]( count_t row,count_t col ){ auto e = _set_item( new QTableWidgetItem,_at( l,col ),font ) ; table->setItem( row,col,e ) ; } ) ; } ) ; }
/* check if o.id can visit field (o.xi, o,yi) */ bool ProximityMap::canVisit(const djk &o) const { /* first check if the field exists */ if(o.xi < 0 || o.yi < 0 || o.xi >= widet || o.yi >= hedet) return false; /* then check if there's free space in the field */ poiid_t k = usedEntries[o.yi][o.xi]; if(k == entries) return false; /* finally check if the field has been visited yet * TODO: performance here can be propably improved */ const poiid_t *entries = _at(o.xi,o.yi); for(int i=k-1; i>=0; i--) if(entries[i] == o.id) return false; return true; }
bool operator () (int i, int j) const { return _at(i,j); }
BitRef operator () (int i, int j) { return _at(i,j); }
template<unsigned N> void BinaryRelation<N>::merge(int i, int j) { //Assert (not _at(i,j), "..."); for (int k=0; k<N; ++k) { BitRef b = _at(j,k); b = b | _at(i,k); } for (int k=0; k<N; ++k) { BitRef b = _at(k,j); b = b | _at(k,i); } }
template<unsigned N> void BinaryRelation<N>::insert(int i) { for (int j=0; j<N; ++j) _at(i,j) = false; for (int j=0; j<N; ++j) _at(j,i) = false; }
template<unsigned N> void BinaryRelation<N>::merge(int i, int j) { for (int k=0; k<N; ++k) { BitRef b = _at(j,k); b = b | _at(i,k); } }
image::const_reference image::operator()(image::size_type x, image::size_type y) const { // std::cout << "x: "<<x<< " y: " << y << std::endl; assert(x < width() && y < height()); return _at(x,y); }
image::reference image::operator()(image::size_type x, image::size_type y) { assert(x < width() && y < height()); return _at(x,y); }
char at(std::size_t _Index) const { return _at(_Index); }
bool operator()(std::size_t i, std::size_t j) const noexcept { assert(i < nodes_count() && j < nodes_count()); return _at(i,j); }
auto neighbors(std::size_t node) { return ranges::view::iota(0u, nodes_count() - 1) | ranges::view::remove_if([=](int i){ return !_at(node, i); }); }
void ProximityMap::pushEntry(const djk &o) { poiid_t *k = &usedEntries[o.yi][o.xi]; assert(*k < entries); _at(o.xi,o.yi)[(*k)++] = o.id; }