@zvenigora/ng-eval-core
Version:
An expression evaluator for Angular
61 lines (60 loc) • 1.68 kB
TypeScript
import { StackType } from '../../interfaces';
/**
* Represents a stack data structure with proper memory management.
* @template T The type of elements in the stack.
*/
export declare class Stack<T> implements StackType<T> {
private _stack;
private _disposed;
/**
* Creates a new instance of the Stack class.
* @param _stack An optional array to initialize the stack.
*/
constructor(_stack?: T[]);
/**
* Check if the stack has been disposed
*/
private checkDisposed;
/**
* Gets the number of elements in the stack.
*/
get length(): number;
/**
* Returns the top element of the stack without removing it.
* @returns The top element of the stack.
*/
peek(): T;
/**
* Removes and returns the top element of the stack.
* @returns The top element of the stack, or undefined if the stack is empty.
*/
pop(): T | undefined;
/**
* Adds an element to the top of the stack.
* @param value The element to be added to the stack.
* @returns The new length of the stack.
*/
push(value: T): number;
/**
* Swaps the positions of the top two elements in the stack.
*/
swap(): void;
/**
* Returns the elements of the stack as an array in reverse order.
*
* @returns An array containing the elements of the stack in reverse order.
*/
asArray(): T[];
/**
* Clears all elements from the stack
*/
clear(): void;
/**
* Properly dispose of the stack and clean up memory
*/
dispose(): void;
/**
* Check if the stack has been disposed
*/
isDisposed(): boolean;
}