typescript-ds-lib
Version:
A collection of TypeScript data structure implementations
39 lines (38 loc) • 1.19 kB
TypeScript
import { BaseCollection } from './base-collection';
export interface LinkedList<T> {
pushBack(element: T): void;
pushFront(element: T): void;
popBack(): T | undefined;
popFront(): T | undefined;
front(): T | undefined;
back(): T | undefined;
insert(element: T, position: number): boolean;
insertBefore(element: T, condition: (element: T) => boolean): boolean;
insertAfter(element: T, condition: (element: T) => boolean): boolean;
removeIf(condition: (element: T) => boolean): boolean;
removeAt(position: number): T | undefined;
forEach(callback: (element: T) => void): void;
get(position: number): T | undefined;
}
export declare class LinkedList<T> extends BaseCollection<T> implements LinkedList<T> {
private head;
private tail;
private length;
constructor();
/**
* Returns true if the list is empty, false otherwise
*/
isEmpty(): boolean;
/**
* Returns the number of elements in the list
*/
size(): number;
/**
* Removes all elements from the list
*/
clear(): void;
/**
* Checks if two lists are equal.
*/
equals(other: LinkedList<T>): boolean;
}