import type { IndexJSON, MatrixValue } from './types.js'; /** * Type representing a single dimension in an Index. * Can be a number, string (for object properties), Range, or ImmutableDenseMatrix. * * INTENTIONAL structural type: Range is defined as a structural type rather than * importing RangeInterface to avoid circular dependencies. The Range class is created * in a separate factory and its interface matches this structural definition. */ export type IndexDimension = number | string | ImmutableDenseMatrix | { size(): number[]; min(): number | undefined; max(): number | undefined; toArray(): number[]; toString(): string; }; interface IndexClass { _dimensions: IndexDimension[]; _sourceSize: (number | null)[]; _isScalar: boolean; } /** * Callback function for Index forEach operations */ export type IndexForEachCallback = (dimension: IndexDimension, index: number, indexObject: IndexClass) => void; export type { IndexJSON }; /** * Interface for ImmutableDenseMatrix (used internally) */ interface ImmutableDenseMatrix { _data: MatrixValue[]; _size: number[]; valueOf(): MatrixValue[]; size(): number[]; toArray(): MatrixValue[]; } export declare const createIndexClass: import("../../utils/factory.js").FactoryFunction} ranges * @return {Index} index * @private */ create(ranges: unknown[]): { /** * Type identifier */ readonly type: string; /** * Index type flag */ readonly isIndex: boolean; /** * Internal array of dimensions * @internal */ _dimensions: IndexDimension[]; /** * Source sizes for boolean array conversions * @internal */ _sourceSize: (number | null)[]; /** * Flag indicating if this index represents a scalar value * @internal */ _isScalar: boolean; /** * Create a clone of the index * @memberof Index * @return {Index} clone */ clone(): /*elided*/ any; /** * Retrieve the size of the index, the number of elements for each dimension. * @memberof Index * @returns {number[]} size */ size(): number[]; /** * Get the maximum value for each of the indexes ranges. * @memberof Index * @returns {number[]} max */ max(): (number | string | undefined)[]; /** * Get the minimum value for each of the indexes ranges. * @memberof Index * @returns {number[]} min */ min(): (number | string | undefined)[]; /** * Loop over each of the ranges of the index * @memberof Index * @param {Function} callback Called for each range with a Range as first * argument, the dimension as second, and the * index object as third. */ forEach(callback: IndexForEachCallback): void; /** * Retrieve the dimension for the given index * @memberof Index * @param {Number} dim Number of the dimension * @returns {Range | null} range */ dimension(dim: number): IndexDimension | null; /** * Test whether this index contains an object property * @returns {boolean} Returns true if the index is an object property */ isObjectProperty(): boolean; /** * Returns the object property name when the Index holds a single object property, * else returns null * @returns {string | null} */ getObjectProperty(): string | null; /** * Test whether this index contains only a single value. * * This is the case when the index is created with only scalar values as ranges, * not for ranges resolving into a single value. * @memberof Index * @return {boolean} isScalar */ isScalar(): boolean; /** * Expand the Index into an array. * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] * @memberof Index * @returns {Array} array */ toArray(): unknown[]; /** * Get the primitive value of the Index, a two dimensional array. * Equivalent to Index.toArray(). * @memberof Index * @returns {Array} array */ valueOf(): unknown[]; /** * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7, [1,2,3]]' * @memberof Index * @returns {String} str */ toString(): string; /** * Get a JSON representation of the Index * @memberof Index * @returns {Object} Returns a JSON object structured as: * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` */ toJSON(): IndexJSON; }; /** * Instantiate an Index from a JSON object * @memberof Index * @param {Object} json A JSON object structured as: * `{"mathjs": "Index", "dimensions": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` * @return {Index} */ fromJSON(json: IndexJSON): { /** * Type identifier */ readonly type: string; /** * Index type flag */ readonly isIndex: boolean; /** * Internal array of dimensions * @internal */ _dimensions: IndexDimension[]; /** * Source sizes for boolean array conversions * @internal */ _sourceSize: (number | null)[]; /** * Flag indicating if this index represents a scalar value * @internal */ _isScalar: boolean; /** * Create a clone of the index * @memberof Index * @return {Index} clone */ clone(): /*elided*/ any; /** * Retrieve the size of the index, the number of elements for each dimension. * @memberof Index * @returns {number[]} size */ size(): number[]; /** * Get the maximum value for each of the indexes ranges. * @memberof Index * @returns {number[]} max */ max(): (number | string | undefined)[]; /** * Get the minimum value for each of the indexes ranges. * @memberof Index * @returns {number[]} min */ min(): (number | string | undefined)[]; /** * Loop over each of the ranges of the index * @memberof Index * @param {Function} callback Called for each range with a Range as first * argument, the dimension as second, and the * index object as third. */ forEach(callback: IndexForEachCallback): void; /** * Retrieve the dimension for the given index * @memberof Index * @param {Number} dim Number of the dimension * @returns {Range | null} range */ dimension(dim: number): IndexDimension | null; /** * Test whether this index contains an object property * @returns {boolean} Returns true if the index is an object property */ isObjectProperty(): boolean; /** * Returns the object property name when the Index holds a single object property, * else returns null * @returns {string | null} */ getObjectProperty(): string | null; /** * Test whether this index contains only a single value. * * This is the case when the index is created with only scalar values as ranges, * not for ranges resolving into a single value. * @memberof Index * @return {boolean} isScalar */ isScalar(): boolean; /** * Expand the Index into an array. * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] * @memberof Index * @returns {Array} array */ toArray(): unknown[]; /** * Get the primitive value of the Index, a two dimensional array. * Equivalent to Index.toArray(). * @memberof Index * @returns {Array} array */ valueOf(): unknown[]; /** * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7, [1,2,3]]' * @memberof Index * @returns {String} str */ toString(): string; /** * Get a JSON representation of the Index * @memberof Index * @returns {Object} Returns a JSON object structured as: * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` */ toJSON(): IndexJSON; }; }>; //# sourceMappingURL=MatrixIndex.d.ts.map