import '../../assert/js/assert.js';
import '../../globals.js';
/**
 * Given a rectangular containing area, takes care of allocating and deallocating smaller rectangular "bins" that fit
 * together inside the area and do not overlap. Optimized more for runtime CPU usage than space currently.
 *
 * For example:
 * #begin canvasExample binPacker 256x256
 * #on
 * var binPacker = new phet.dot.BinPacker( new dot.Bounds2( 0, 0, 256, 256 ) );
 * var bins = [];
 * for ( var i = 0; i < 100; i++ ) {
 *   var bin = binPacker.allocate( Math.random() * 64, Math.random() * 64 );
 *   if ( bin ) {
 *     bins.push( bin );
 *   }
 * }
 * #off
 *
 * context.strokeStyle = '#000';
 * bins.forEach( function( bin ) {
 *   var bounds = bin.bounds;
 *   context.strokeRect( bounds.x, bounds.y, bounds.width, bounds.height );
 * } );
 * #end canvasExample
 *
 * @author Sharfudeen Ashraf
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import Bounds2 from './Bounds2.js';
export default class BinPacker {
    private readonly rootBin;
    /**
     * Creates a BinPacker with the specified containing bounds.
     *
     * @param bounds - The available bounds to pack bins inside.
     */
    constructor(bounds: Bounds2);
    /**
     * Allocates a bin with the specified width and height if possible (returning a {Bin}), otherwise returns null.
     */
    allocate(width: number, height: number): Bin | null;
    /**
     * Deallocates a bin, so that its area can be reused by future allocations.
     *
     * @param bin - The bin that was returned from allocate().
     */
    deallocate(bin: Bin): void;
    toString(): string;
    static Bin: typeof Bin;
}
export declare class Bin {
    bounds: Bounds2;
    private parent;
    private isSplit;
    private isUsed;
    children: Bin[];
    /**
     * A rectangular bin that can be used itself or split into sub-bins.
     */
    constructor(bounds: Bounds2, parent: Bin | null);
    /**
     * Finds an unused bin with open area that is at least width-x-height in size. (dot-internal)
     */
    findAvailableBin(width: number, height: number): Bin | null;
    /**
     * Splits this bin into multiple child bins, and returns the child with the dimensions (width,height). (dot-internal)
     */
    split(width: number, height: number): Bin;
    /**
     * Mark this bin as used. (dot-internal)
     */
    use(): void;
    /**
     * Mark this bin as not used, and attempt to collapse split parents if all children are unused. (dot-internal)
     */
    unuse(): void;
    /**
     * If our bin can be collapsed (it is split and has children that are not used AND not split), then we will become
     * not split, and will remove our children. If successful, it will also call this on our parent, fully attempting
     * to clean up unused data structures.
     */
    private attemptToCollapse;
    toString(): string;
}
//# sourceMappingURL=BinPacker.d.ts.map