/** * ============================================================================ * IMPORTS * ============================================================================ * @hidden */ import type { Entity } from "./Entity"; import type { Template } from "./Template"; import type { IDisposer } from "./Disposer"; import { EventDispatcher, Events } from "./EventDispatcher"; import type { Optional } from "./Type"; export interface IListEvents { /** * All items were removed, by `clear()` or `setAll()`. */ clear: { oldValues: Array; }; /** * An item was added to the end of the list. */ push: { newValue: A; }; /** * An item was inserted at `index`. */ insertIndex: { index: number; newValue: A; }; /** * The item at `index` was replaced. */ setIndex: { index: number; oldValue: A; newValue: A; }; /** * The item at `index` was removed. */ removeIndex: { index: number; oldValue: A; }; /** * An item was moved from `oldIndex` to `newIndex`. */ moveIndex: { oldIndex: number; newIndex: number; value: A; }; /** * Two items swapped places. */ swap: { a: A; b: A; }; } /** * An ordered list of items that dispatches events as items are added, removed * or moved. */ export declare class List { /** * List values. */ protected _values: Array; events: EventDispatcher>>; /** * Constructor * * @param initial Initial list of values to add to list */ constructor(initial?: Array); /** * An array of values in the list. * * Don't change this array directly: use methods like `push()` and * `removeIndex()`, which dispatch the list's events. * * @readonly * @return List values */ get values(): Array; /** * Checks if list contains specific item reference. * * @param value Item to search for * @return `true` if found, `false` if not found */ contains(value: T): boolean; /** * Removes all copies of an item from the list. * * @param value An item to remove */ removeValue(value: T): void; /** * Searches the list for specific item and returns its index. * * @param value An item to search for * @return Index or -1 if not found */ indexOf(value: T): number; /** * Number of items in list. * * @readonly * @return Number of items */ get length(): number; /** * Checks if there's a value at specific index. * * @param index Index * @return Value exists? */ hasIndex(index: number): boolean; /** * Returns an item at specified index. * * @param index Index * @return List item */ getIndex(index: number): T | undefined; protected _onPush(newValue: T): void; protected _onInsertIndex(index: number, newValue: T): void; protected _onSetIndex(index: number, oldValue: T, newValue: T): void; protected _onSwap(a: T, b: T): void; protected _onRemoveIndex(index: number, oldValue: T): void; protected _onMoveIndex(oldIndex: number, newIndex: number, value: T): void; protected _onClear(oldValues: Array): void; /** * Replaces the value at `index`, which must already exist. * * @param index Index * @param value New value * @return Old value */ setIndex(index: number, value: T): T; /** * Inserts an item at `index`, moving the items from there on one place * further. * * @param index Index * @param value An item to add * @return Added item */ insertIndex(index: number, value: K): K; /** * Swaps two items in the list. * * @param a Index of the first item * @param b Index of the second item */ swap(a: number, b: number): void; /** * Removes a value at specific index. * * @param index Index of value to remove * @return Removed value */ removeIndex(index: number): T; /** * Moves an item to `toIndex`, or to the end of the list if `toIndex` is not * set. An item that is not in the list yet is added. * * @param value Item to move * @param toIndex Index to place item at * @return Moved item */ moveValue(value: K, toIndex?: number): K; /** * Adds an item to the end of the list. * * @param value An item to add * @return Added item */ push(value: K): K; /** * Adds an item as a first item in the list. * * @param value An item to add * @return Added item */ unshift(value: K): K; /** * Adds multiple items to the end of the list. * * @param values An Array of items to add */ pushAll(values: Array): void; /** * Adds all items of another list to the end of this one. * * @param source A list to copy items from */ copyFrom(source: this): void; /** * Returns the last item from the list, and removes it. * * @return Item */ pop(): Optional; /** * Returns the first item from the list, and removes it. * * @return Item */ shift(): Optional; /** * Replaces all items in the list with `newArray`. * * @param newArray New items */ setAll(newArray: Array): void; /** * Removes all items from the list. */ clear(): void; /** * Returns an ES6 iterator for the list. */ [Symbol.iterator](): Iterator; /** * Calls `f` for each item in the list, with the item and its index. */ each(f: (value: T, index: number) => void): void; /** * Calls `f` for each item in the list, from last to first, with the item * and its index. */ eachReverse(f: (value: T, index: number) => void): void; } /** * A version of a [[List]] where the elements are disposed automatically when * removed from the list, unless `autoDispose` is set to `false`. */ export declare class ListAutoDispose extends List implements IDisposer { /** * Automatically disposes elements that are removed from the list. * * @default true */ autoDispose: boolean; private _disposed; /** * Swaps two items in the list, without disposing them. * * @param a Index of the first item * @param b Index of the second item */ swap(a: number, b: number): void; protected _onSetIndex(index: number, oldValue: A, newValue: A): void; protected _onRemoveIndex(index: number, oldValue: A): void; protected _onClear(oldValues: Array): void; protected _dispose(): void; isDisposed(): boolean; dispose(): void; } /** * A version of a [[List]] that is able to create new elements as well as * apply additional settings to newly created items. * * @see {@link https://www.amcharts.com/docs/v5/concepts/settings/list-templates/} for more info */ export declare class ListTemplate extends ListAutoDispose { template: Template; make: () => A; constructor(template: Template, make: () => A); protected _dispose(): void; } //# sourceMappingURL=List.d.ts.map