Files
dotfiles/cabal/share/doc/x86_64-osx-ghc-7.10.1/MissingH-1.3.0.1/html/Data-BinPacking.html
2015-04-05 17:47:08 +02:00

22 lines
12 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.BinPacking</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-BinPacking.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">MissingH-1.3.0.1: Large utility library</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>Copyright (C) 2008-2011 John Goerzen</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>John Goerzen &lt;jgoerzen@complete.org&gt; </td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Data.BinPacking</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Tools for packing into bins</p><p>Written by John Goerzen, jgoerzen@complete.org</p><p>This module is designed to solve this type of problem: Given a bunch of
objects of varying sizes, what is the best possible way to pack them into
fixed-size bins? This can be used, for instance, by the datapacker program
to pack files onto CDs or DVDs; by manufacturing environments to pack
physical items into physicl bins; etc.</p><p>A description of bin packing algorithms can be found at
<a href="http://en.wikipedia.org/wiki/Bin_packing_problem">http://en.wikipedia.org/wiki/Bin_packing_problem</a>.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">type</span> <a href="#t:BinPacker">BinPacker</a> = (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; [size] -&gt; [(size, obj)] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Either.html#t:Either">Either</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj) [[(size, obj)]]</li><li class="src short"><span class="keyword">data</span> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a href="#t:BinPackerError">BinPackerError</a> size obj<ul class="subs"><li>= <a href="#v:BPTooFewBins">BPTooFewBins</a> [(size, obj)]</li><li>| <a href="#v:BPSizeTooLarge">BPSizeTooLarge</a> size (size, obj)</li><li>| <a href="#v:BPOther">BPOther</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></li></ul></li><li class="src short"><a href="#v:packByOrder">packByOrder</a> :: <a href="Data-BinPacking.html#t:BinPacker">BinPacker</a></li><li class="src short"><a href="#v:packLargeFirst">packLargeFirst</a> :: <a href="Data-BinPacking.html#t:BinPacker">BinPacker</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:BinPacker" class="def">BinPacker</a> = (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; [size] -&gt; [(size, obj)] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Either.html#t:Either">Either</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj) [[(size, obj)]]</p><div class="doc"><p>The primary type for bin-packing functions.</p><p>These functions take a list of size of bins. If every bin is the same size,
you can pass <code>repeat binSize</code> to pass an infinite list of bins if the
same size. Any surplus bins will simply be ignored. </p><pre>[size] is the sizes of bins
[(size, obj)] is the sizes and objects
result is Either error or results</pre></div></div><div class="top"><p class="src"><span class="keyword">data</span> (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a name="t:BinPackerError" class="def">BinPackerError</a> size obj</p><div class="doc"><p>Potential errors returned as Left values by <code><a href="Data-BinPacking.html#t:BinPacker">BinPacker</a></code> functions.
Calling <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#v:show">show</a></code> on this value will produce a nice error message suitable for
display. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:BPTooFewBins" class="def">BPTooFewBins</a> [(size, obj)]</td><td class="doc"><p>Ran out of bins; attached value is the list of objects that do not fit</p></td></tr><tr><td class="src"><a name="v:BPSizeTooLarge" class="def">BPSizeTooLarge</a> size (size, obj)</td><td class="doc"><p>Bin size1 exceeded by at least the given object and size</p></td></tr><tr><td class="src"><a name="v:BPOther" class="def">BPOther</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></td><td class="doc"><p>Other error</p></td></tr></table></div><div class="subs instances"><p id="control.i:BinPackerError" class="caption collapser" onclick="toggleSection('i:BinPackerError')">Instances</p><div id="section.i:BinPackerError" class="show"><table><tr><td class="src">(<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Eq.html#t:Eq">Eq</a> obj, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Read.html#t:Read">Read</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Read.html#t:Read">Read</a> obj, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Read.html#t:Read">Read</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Prelude.html#t:Num">Num</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Ord.html#t:Ord">Ord</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> size, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> obj) =&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Error.html#t:Error">Error</a> (<a href="Data-BinPacking.html#t:BinPackerError">BinPackerError</a> size obj)</td><td class="doc"><p>Let us use this as part of the Either monad </p></td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:packByOrder" class="def">packByOrder</a> :: <a href="Data-BinPacking.html#t:BinPacker">BinPacker</a></p><div class="doc"><p>Pack objects into bins, preserving order. Objects will be taken from the
input list one by one, and added to each bin until the bin is full. Work will
then proceed on the next bin. No attempt is made to optimize allocations to
bins. This is the simplest and most naive bin-packing algorithm, but
may not make very good use of bin space. </p></div></div><div class="top"><p class="src"><a name="v:packLargeFirst" class="def">packLargeFirst</a> :: <a href="Data-BinPacking.html#t:BinPacker">BinPacker</a></p><div class="doc"><p>Pack objects into bins. For each bin, start with the largest objects,
and keep packing the largest object from the remainder until no object can
be found to put in the bin. This is substantially more efficient than
<code><a href="Data-BinPacking.html#v:packByOrder">packByOrder</a></code>, but requires sorting the input. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.0</p></div></body></html>