本文整理汇总了PHP中ItemList::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemList::insert方法的具体用法?PHP ItemList::insert怎么用?PHP ItemList::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCompare
function testCompare()
{
$box1 = new TestItem('Small', 20, 20, 2, 100, true);
$box2 = new TestItem('Large', 200, 200, 20, 1000, true);
$box3 = new TestItem('Medium', 100, 100, 10, 500, true);
$list = new ItemList();
$list->insert($box1);
$list->insert($box2);
$list->insert($box3);
$sorted = [];
while (!$list->isEmpty()) {
$sorted[] = $list->extract();
}
self::assertEquals(array($box2, $box3, $box1), $sorted);
}
示例2: testVolumeUtilisation
function testVolumeUtilisation()
{
$box = new TestBox('Box', 10, 10, 10, 10, 10, 10, 10, 10);
$item = new TestItem('Item', 5, 10, 10, 10);
$boxItems = new ItemList();
$boxItems->insert($item);
$packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4);
self::assertEquals(50, $packedBox->getVolumeUtilisation());
}
示例3: testWeightRedistribution
public function testWeightRedistribution()
{
$box = new TestBox('Box', 370, 375, 60, 140, 364, 374, 40, 3000);
$boxList = new BoxList();
$boxList->insert($box);
$item1 = new TestItem('Item #1', 230, 330, 6, 320, true);
$item2 = new TestItem('Item #2', 210, 297, 5, 187, true);
$item3 = new TestItem('Item #3', 210, 297, 11, 674, true);
$item4 = new TestItem('Item #4', 210, 297, 3, 82, true);
$item5 = new TestItem('Item #5', 206, 295, 4, 217, true);
$box1Items = new ItemList();
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item1);
$box1Items->insert(clone $item5);
$box2Items = new ItemList();
$box2Items->insert(clone $item3);
$box2Items->insert(clone $item1);
$box2Items->insert(clone $item1);
$box2Items->insert(clone $item1);
$box2Items->insert(clone $item1);
$box2Items->insert(clone $item2);
$box3Items = new ItemList();
$box3Items->insert(clone $item5);
$box3Items->insert(clone $item4);
$packedBox1 = new PackedBox($box, $box1Items, 0, 0, 0, 0);
$packedBox2 = new PackedBox($box, $box2Items, 0, 0, 0, 0);
$packedBox3 = new PackedBox($box, $box3Items, 0, 0, 0, 0);
$packedBoxList = new PackedBoxList();
$packedBoxList->insert($packedBox1);
$packedBoxList->insert($packedBox2);
$packedBoxList->insert($packedBox3);
$redistributor = new WeightRedistributor($boxList);
$packedBoxes = $redistributor->redistributeWeight($packedBoxList);
$packedItemCount = 0;
foreach (clone $packedBoxes as $packedBox) {
$packedItemCount += $packedBox->getItems()->count();
}
self::assertEquals(3070, (int) $packedBoxes->getWeightVariance());
}
示例4: testWeightVariance
function testWeightVariance()
{
$box = new TestBox('Box', 10, 10, 10, 10, 10, 10, 10, 10);
$item = new TestItem('Item', 5, 10, 10, 10, true);
$boxItems = new ItemList();
$boxItems->insert($item);
$packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4);
$packedBoxList = new PackedBoxList();
$packedBoxList->insert($packedBox);
self::assertEquals(0, $packedBoxList->getWeightVariance());
}
示例5: testPackSingleItemFitsBetterRotated
public function testPackSingleItemFitsBetterRotated()
{
$box = new TestBox('Le box', 400, 300, 10, 10, 396, 296, 8, 1000);
$items = new ItemList();
$items->insert(new TestItem('Item 1', 250, 290, 2, 200));
$packer = new Packer();
$packedItems = $packer->packBox($box, $items);
self::assertEquals(1, $packedItems->count());
}