boxpacker

package module
v0.0.0-...-b435fc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HEAP_ERR_NOT_PACKEDBOX       = "The type of the object being returned is not PackedBox."
	HEAP_ERR_NOT_BOX             = "The type of the object being returned is not Box."
	HEAP_ERR_NOT_ITEM            = "The type of the object being returned is not Item."
	HEAP_ERR_NOT_HEAPABLE        = "Proper interface is not implemented on this object."
	HEAP_ERR_INDEX_OUT_OF_BOUNDS = "Given index is out of bounds."
)

Functions

func AddBox

func AddBox(box *Box)

func AddItem

func AddItem(item *Item, qty int)

func Debugf

func Debugf(format string, args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func ItemCompare

func ItemCompare(i, j MinHeapable) bool

func NewPacker

func NewPacker()

func RedistributeWeight

func RedistributeWeight(originalBoxes MinHeap)

Given a solution set of packed boxes, repack them to achieve optimum weight distribution

func Report

func Report(packedBoxes *MinHeap)

func Uline

func Uline()

Types

type Box

type Box struct {
	Reference   string
	OuterWidth  int
	OuterLength int
	OuterDepth  int
	EmptyWeight int
	InnerWidth  int
	InnerLength int
	InnerDepth  int
	InnerVolume int
	MaxWeight   int
}

func CalcOuterDims

func CalcOuterDims(b *Box) *Box

func CalcVolBox

func CalcVolBox(b *Box) *Box

func NewTestBox

func NewTestBox(Reference string, OuterWidth int, OuterLength int, OuterDepth int, EmptyWeight int, InnerWidth int, InnerLength int, InnerDepth int, MaxWeight int) Box

func (Box) BoxInnerVolume

func (i Box) BoxInnerVolume() int

func (Box) BoxWeight

func (i Box) BoxWeight() int

func (Box) ItemCount

func (i Box) ItemCount() int

dummy funcs, only packed box uses these

func (Box) Priority

func (i Box) Priority() int

type Item

type Item struct {
	Description string
	Width       int
	Length      int
	Depth       int
	Volume      int
	Weight      int
}

func CalcVolItem

func CalcVolItem(i *Item) *Item

func NewTestItem

func NewTestItem(Description string, Width int, Length int, Depth int, Weight int) Item

func (Item) BoxInnerVolume

func (i Item) BoxInnerVolume() int

func (Item) BoxWeight

func (i Item) BoxWeight() int

func (Item) ItemCount

func (i Item) ItemCount() int

dummy funcs, only packed box uses these

func (Item) Priority

func (i Item) Priority() int

type MinHeap

type MinHeap []MinHeapable
var (
	Items                   *MinHeap
	Boxes                   *MinHeap
	PACKER_ERR_ITEM_TOO_BIG = "The Item is too large for any box."
)

func NewMinHeap

func NewMinHeap() *MinHeap

func Pack

func Pack() *MinHeap

Pack items into boxes

func (*MinHeap) AtIndex

func (mh *MinHeap) AtIndex(i int) (x MinHeapable, err error)

Returns the item at index i

func (*MinHeap) Copy

func (mh *MinHeap) Copy() *MinHeap

func (*MinHeap) ItemAtIndex

func (mh *MinHeap) ItemAtIndex(i int) (x Item, err error)

func (MinHeap) Len

func (mh MinHeap) Len() int

func (MinHeap) Less

func (mh MinHeap) Less(i, j int) bool

func (*MinHeap) Peek

func (mh *MinHeap) Peek() interface{}

func (*MinHeap) PeekBox

func (mh *MinHeap) PeekBox() *Box

func (*MinHeap) PeekItem

func (mh *MinHeap) PeekItem() *Item

func (*MinHeap) PeekPackedBox

func (mh *MinHeap) PeekPackedBox() *PackedBox

func (*MinHeap) Pop

func (mh *MinHeap) Pop() interface{}

func (*MinHeap) PopBox

func (mh *MinHeap) PopBox() *Box

func (*MinHeap) PopItem

func (mh *MinHeap) PopItem() *Item

func (*MinHeap) PopPackedBox

func (mh *MinHeap) PopPackedBox() *PackedBox

func (*MinHeap) Push

func (mh *MinHeap) Push(item interface{})

func (*MinHeap) PushBox

func (mh *MinHeap) PushBox(box Box)

func (*MinHeap) PushItem

func (mh *MinHeap) PushItem(item Item)

Additional functions; wrappers to make sure the indended type is what is put in; satisfies PackerMinHeapInterface Could be replaced by Push itself.

func (*MinHeap) PushPackedBox

func (mh *MinHeap) PushPackedBox(packedbox PackedBox)

func (*MinHeap) RemoveAt

func (mh *MinHeap) RemoveAt(i int) (err error)

func (MinHeap) Swap

func (mh MinHeap) Swap(i, j int)

type MinHeapable

type MinHeapable interface {
	Priority() int
	// packed box only
	ItemCount() int
	BoxInnerVolume() int
	BoxWeight() int
}

type PackedBox

type PackedBox struct {
	Box             Box
	Items           MinHeap
	Weight          int
	RemainingWidth  int
	RemainingLength int
	RemainingDepth  int
	RemainingWeight int
}

func NewPackedBox

func NewPackedBox(box Box, itemList *MinHeap, remainingWidth int, remainingLength int, remainingDepth int, remainingWeight int) *PackedBox

func VolumePackerPack

func VolumePackerPack(box Box, items *MinHeap) *PackedBox

func (PackedBox) BoxInnerVolume

func (pb PackedBox) BoxInnerVolume() int

func (PackedBox) BoxWeight

func (pb PackedBox) BoxWeight() int

func (PackedBox) ItemCount

func (pb PackedBox) ItemCount() int

func (PackedBox) Priority

func (i PackedBox) Priority() int

type PackerMinHeapInterface

type PackerMinHeapInterface interface {
	heap.Interface
	Copy() *MinHeap
	AtIndex(i int)
	RemoveAt(i int)
	PopItem() *Item
	PopBox() *Box
	PeekItem() *Item
	ItemAtIndex(i int)
	PeekBox() *Box
	PushItem(item Item)
	PushBox(box Box)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL