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
@type t() :: %ExBoxPacker.Result.PackedBoxList{ boxes: [ExBoxPacker.Result.PackedBox.t()], sorter: module() }
Functions
@spec count(t()) :: non_neg_integer()
@spec from_list([ExBoxPacker.Result.PackedBox.t()], module()) :: t()
@spec insert(t(), ExBoxPacker.Result.PackedBox.t()) :: t()
@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.
@spec top(t()) :: ExBoxPacker.Result.PackedBox.t()
The single best box per the sorter.