void Sort() { // if(allow_rotation) // std::transform(contentVector.begin(), contentVector.end(), contentVector.begin(), MakeHorizontal()); std::sort( contentVector.begin(), contentVector.end(), GreatestWidthThenGreatestHeightSort() ); }
ContentAccumulator<_T>& operator += ( const typename Content<_T>::Vector & content ) { contentVector.insert( contentVector.end(), content.begin(), content.end() ); return *this; }
bool Fits( const Content<_T> &content ) const { if( (content.coord.x + content.size.w) > w ) return false; if( (content.coord.y + content.size.h) > h ) return false; for(typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++) { if( content.intersects( *itor ) ) return false; } return true; }
bool Place(const typename Content<_T>::Vector &contentVector, typename Content<_T>::Vector &remainder) { bool placedAll = true; for(typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++) { const Content<_T> & content = *itor; if( Place( content ) == false ) { placedAll = false; remainder.push_back( content ); } } return placedAll; }