ExBoxPacker.Result.PackedBoxList (ExBoxPacker v0.2.0)

Copy Markdown View Source

A collection of ExBoxPacker.Result.PackedBox with aggregate statistics. Port of BoxPacker's PackedBoxList. Iteration/to_list order is defined by the configured PackedBoxSorter.

Summary

Types

t()

@type t() :: %ExBoxPacker.Result.PackedBoxList{
  boxes: [ExBoxPacker.Result.PackedBox.t()],
  sorter: module()
}

Functions

count(packed_box_list)

@spec count(t()) :: non_neg_integer()

from_list(boxes, sorter \\ DefaultPackedBoxSorter)

@spec from_list([ExBoxPacker.Result.PackedBox.t()], module()) :: t()

insert(list, box)

@spec insert(t(), ExBoxPacker.Result.PackedBox.t()) :: t()

mean_item_weight(packed_box_list)

@spec mean_item_weight(t()) :: float()

mean_weight(packed_box_list)

@spec mean_weight(t()) :: float()

new(sorter \\ DefaultPackedBoxSorter)

@spec new(module()) :: t()

to_list(packed_box_list)

@spec to_list(t()) :: [ExBoxPacker.Result.PackedBox.t()]

All packed boxes, ordered by the configured sorter.

insert/2 prepends, so boxes is stored in reverse insertion order; we reverse first to recover insertion order before the (stable) sort. This makes the sorter's ties resolve in insertion order, matching PHP's PackedBoxList (which appends and relies on usort being stable) — notably the weight-descending order established by WeightRedistributor.

top(list)

@spec top(t()) :: ExBoxPacker.Result.PackedBox.t()

The single best box per the sorter.

volume_utilisation(packed_box_list)

@spec volume_utilisation(t()) :: float()

weight_variance(list)

@spec weight_variance(t()) :: float()