import { ArrayIterator, IArrayLike, IIterable } from './iteration'; /** * A finite-length sequence of indexable values. */ export interface ISequence extends IIterable { /** * The length of the sequence. * * #### Notes * This is a read-only property. */ length: number; /** * Get the value at the specified index. * * @param index - The positive integer index of interest. * * @returns The value at the specified index. * * #### Undefined Behavior * An `index` which is non-integral or out of range. */ at(index: number): T; } /** * A sequence which allows mutation of the underlying values. */ export interface IMutableSequence extends ISequence { /** * Set the value at the specified index. * * @param index - The positive integer index of interest. * * @param value - The value to set at the specified index. * * #### Undefined Behavior * An `index` which is non-integral or out of range. */ set(index: number, value: T): void; } /** * A type alias for a sequence or builtin array-like object. * * #### Notes * The [[seq]] function can be used to produce an [[ISequence]] for * objects of this type. This allows sequence algorithms to operate * on these objects in a uniform fashion. */ export declare type SequenceOrArrayLike = ISequence | IArrayLike; /** * A type alias for a mutable sequence or builtin array-like object. * * #### Notes * The [[mseq]] function can be used to produce an [[IMutableSequence]] * for objects of this type. This allows sequence algorithms to operate * on these objects in a uniform fashion. */ export declare type MutableSequenceOrArrayLike = IMutableSequence | IArrayLike; /** * Cast a sequence or array-like object to a sequence. * * @param object - The sequence or array-like object of interest. * * @returns A sequence for the given object. * * #### Notes * This function allows sequence algorithms to operate on user-defined * sequence types and builtin array-like objects in a uniform fashion. */ export declare function asSequence(object: SequenceOrArrayLike): ISequence; /** * Cast a mutable sequence or array-like object to a mutable sequence. * * @param object - The sequence or array-like object of interest. * * @returns A mutable sequence for the given object. * * #### Notes * This function allows sequence algorithms to operate on user-defined * sequence types and builtin array-like objects in a uniform fashion. */ export declare function asMutableSequence(object: MutableSequenceOrArrayLike): IMutableSequence; /** * A sequence for an array-like object. * * #### Notes * This sequence can be used for any builtin JS array-like object. */ export declare class ArraySequence implements ISequence { /** * Construct a new array sequence. * * @param source - The array-like object of interest. */ constructor(source: IArrayLike); /** * The length of the sequence. * * #### Notes * This is a read-only property. */ readonly length: number; /** * Create an iterator over the object's values. * * @returns A new iterator which traverses the object's values. */ iter(): ArrayIterator; /** * Get the value at the specified index. * * @param index - The positive integer index of interest. * * @returns The value at the specified index. * * #### Undefined Behavior * An `index` which is non-integral or out of range. */ at(index: number): T; protected _source: IArrayLike; } /** * A sequence for a mutable array-like object. * * #### Notes * This sequence can be used for any builtin JS array-like object. */ export declare class MutableArraySequence extends ArraySequence implements IMutableSequence { /** * Set the value at the specified index. * * @param index - The positive integer index of interest. * * @param value - The value to set at the specified index. * * #### Undefined Behavior * An `index` which is non-integral or out of range. */ set(index: number, value: T): void; }