123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /**
- * Defines an array and its length.
- * It can be helpful to group result from both Arrays and smart arrays in one structure.
- */
- export interface ISmartArrayLike<T> {
- /**
- * The data of the array.
- */
- data: Array<T>;
- /**
- * The active length of the array.
- */
- length: number;
- }
- /**
- * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
- */
- export declare class SmartArray<T> implements ISmartArrayLike<T> {
- /**
- * The full set of data from the array.
- */
- data: Array<T>;
- /**
- * The active length of the array.
- */
- length: number;
- protected _id: number;
- /**
- * Instantiates a Smart Array.
- * @param capacity defines the default capacity of the array.
- */
- constructor(capacity: number);
- /**
- * Pushes a value at the end of the active data.
- * @param value defines the object to push in the array.
- */
- push(value: T): void;
- /**
- * Iterates over the active data and apply the lambda to them.
- * @param func defines the action to apply on each value.
- */
- forEach(func: (content: T) => void): void;
- /**
- * Sorts the full sets of data.
- * @param compareFn defines the comparison function to apply.
- */
- sort(compareFn: (a: T, b: T) => number): void;
- /**
- * Resets the active data to an empty array.
- */
- reset(): void;
- /**
- * Releases all the data from the array as well as the array.
- */
- dispose(): void;
- /**
- * Concats the active data with a given array.
- * @param array defines the data to concatenate with.
- */
- concat(array: any): void;
- /**
- * Returns the position of a value in the active data.
- * @param value defines the value to find the index for
- * @returns the index if found in the active data otherwise -1
- */
- indexOf(value: T): number;
- /**
- * Returns whether an element is part of the active data.
- * @param value defines the value to look for
- * @returns true if found in the active data otherwise false
- */
- contains(value: T): boolean;
- private static _GlobalId;
- }
- /**
- * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
- * The data in this array can only be present once
- */
- export declare class SmartArrayNoDuplicate<T> extends SmartArray<T> {
- private _duplicateId;
- /**
- * Pushes a value at the end of the active data.
- * THIS DOES NOT PREVENT DUPPLICATE DATA
- * @param value defines the object to push in the array.
- */
- push(value: T): void;
- /**
- * Pushes a value at the end of the active data.
- * If the data is already present, it won t be added again
- * @param value defines the object to push in the array.
- * @returns true if added false if it was already present
- */
- pushNoDuplicate(value: T): boolean;
- /**
- * Resets the active data to an empty array.
- */
- reset(): void;
- /**
- * Concats the active data with a given array.
- * This ensures no duplicate will be present in the result.
- * @param array defines the data to concatenate with.
- */
- concatWithNoDuplicate(array: any): void;
- }
|