Hey guys, i'm doing a Bin Packing project and need some help with the Overloading of the operator < !
I have a list of objects pack, as a vector.
my packs objects are defined by height and width. For the method First Fit Decreasing Height i need a Decreasing order of my vector of objects pack.
I did like this and worked fine:
Class BinPacking i have this
1 2
|
sort(PackOBJ.begin(),PackOBJ.end());//order crescent
reverse(PackOBJ.begin(),PackOBJ.end());//reverse to decreasing
|
And in my Pack Class i have this
1 2 3 4
|
bool Pack::operator< (const Pack& other)
{
return this->height < other.height;
}
|
And it's working, but i also wanted to order by width. In my case i have a pack that is 1x1 and 2x1 (width x height) and it is putting the 1x1 before the 2x1, i want use the bigger items first. I can't just get the total area, it have to be decreasing HEIGHT, but i want it also decreasing width. How can i do it?
i tried like this and did't work:
1 2 3 4
|
bool Pack::operator< (const Pack& other)
{
return (this->height < other.height)&&(this->width < other.width);
}
|
and i fail...LOL
any help?