import { SetPairCallback } from '../utils/btree';
import { CellCoords, CellRangeCoords, CartesianDirection } from "@sheetxl/common";
import { Run } from "../run/RunUtils";
/**
 * Callback for visiting the Map
 *
 * @returns A break obj value stop visiting.
 */
/**
 * The return type for a Visitor.
 */
export type CoordsMapVisitorResults<V> = {
    /**
     * If specified then the visiting will stop and return the value as the result of the forEach.
     */
    break?: any;
    /**
     * If specified will update the value in the map
     */
    update?: V;
    /**
     * If specified will delete the value in the map
     */
    delete?: boolean;
    /**
     * Jump to another location within the map. Goto will be ignored if break is specified.
     */
    goto?: CellCoords;
};
/**
 * Callback for the visiting map.
 */
export type CoordsMapVisitor<V> = (coords: CellCoords, value: V) => CoordsMapVisitorResults<V> | void;
export interface CoordsMapScanOptions {
    /**
     * If not specified or null then all cells will be visited.
     * @defaultValue null
     */
    bounds?: Partial<CellRangeCoords>;
    /**
     * If set then start not at the beginning but at the specified cell.
     */
    from?: CellCoords;
    /**
     * Determines the direction that cells are visited.
     * @defaultValue true
     */
    isRowScan?: boolean;
    /**
     * If true will allow for value and deletes while scanning. This makes scanning slightly slower
     * but allows for single read/writes if modifying.
     * @remarks
     * Currently editMode is not support for emptyValue when using skipEmpty.
  
     * @defaultValue false;
     */
    editMode?: boolean;
}
export interface CoordsMapKeyPair<V> {
    coords: CellCoords;
    /**
     * If null then this will remove the cell.
     */
    value: V | null;
}
/**
 * Stores values with a CellCoords key.
 * This acts like a hashmap but has additional to scan in vertical or horizontal directions.
 * Additionally it can be 'quick cloned' for undo/redo support.
 */
export default class CoordsMap<V> {
    private _bTreeRows;
    private _bTreeCols;
    private _maxCoords;
    constructor(maxCoords?: CellCoords);
    set(coords: CellCoords, value: V | null, overwrite?: SetPairCallback<CellCoords, V>): void;
    /**
     * Sets the cells in the 2d space.
     * @param cells
     */
    setBatch(cells: CoordsMapKeyPair<V>[], callback?: SetPairCallback<CellCoords, V>): void;
    deleteKeys(keys: CellCoords[], callback?: SetPairCallback<CellCoords, V>): number;
    delete(coordsInput: CellCoords, callback?: SetPairCallback<CellCoords, V>): boolean;
    /**
     * scan will walk all index elements from the top/left to the bottom/right
     * @param visitor the visitor for scanning
     * @param isRowScan the scan direction will have a slight performance impact. If bounds is set then we scan the direction that is shortest
     */
    forEach(visitor: CoordsMapVisitor<V>, options?: CoordsMapScanOptions): void;
    /**
     * Scans from coords in a given direction to the end of row/col span or until shouldContinue returns false
     * @returns the last coord or null if no coords were found
     */
    findNextRun(coords: CellCoords, direction: CartesianDirection, shouldContinue?: (value: V, coords: CellCoords) => boolean): Run<boolean>;
    /**
     * Returns a mutable clone of the current map.
     * @remarks
     * Any changes made to the cloned map will not effect the original map.
     */
    clone(): CoordsMap<V>;
    /**
     * Return the value at the given coords.
     */
    get(coords: CellCoords): V | undefined;
    get size(): number;
    /**
     * The largestCellCoord in the map.
     * @remarks This is the virtual coord that will have the largest rowIndex and largest colIndex but
     * may not be an actual cell in the map.
     *
     * @returns the largest virtual cell coord in the map.
     */
    largestCellCoords(bounds?: CellRangeCoords): CellCoords;
    /**
     * If no bounds then returns the smallest for the entire map.
     * If bounds is provided then returns the smallest within the bounds.
     * @param bounds
     * @returns
     */
    smallestCellCoords(bounds?: CellRangeCoords): CellCoords;
    maxCellCoords(): CellCoords | null;
    clear(): void;
    /**
     * Shifts the cells in a given direction by the amount of the cells. When shifting Down/Right this will create spaces but when shifting Up/Left this will remove spaces (and data).
     *
     * @param ranges
     * @param direction
     */
    shiftCells(ranges: CellRangeCoords[], direction: CartesianDirection, onDelete?: (from: CellCoords, value: V) => void, onSetPair?: (to: CellCoords, value: V) => void): void;
    /**
     * Returns an irregular array of arrays that represents all of the relative
     * coords in the map.
     * @param coordsMap
     * @param options
     */
    to2DArray(options?: CoordsMapScanOptions): V[][];
}
export { CoordsMap };
//# sourceMappingURL=CoordsMap.d.ts.map