Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare module 'linked-list' {
- export default LinkedList;
- export interface ListItem {
- next: ListItem;
- prev: ListItem;
- list: LinkedList | null;
- append (item: ListItem): ListItem;
- detach (): boolean;
- prepend (item: ListItem): ListItem;
- }
- class LinkedList {
- head: ListItem;
- tail: ListItem;
- /** Creates a new List: A linked list is a bit like an Array,
- * but knows nothing about how many items are in it, and
- * knows only about its first (`head`) and last (`tail`)
- * items. Each item (e.g. `head`, `tail`, &c.) knows which
- * item comes before or after it (its more like the
- * implementation of the DOM in JavaScript).
- * @param [items]
- */
- constructor (...items: ListItem[]);
- static from (items: ListItem[]): LinkedList;
- static of (...items: ListItem[]): LinkedList;
- append (item: ListItem): ListItem;
- prepend (item: ListItem): ListItem;
- toArray (): any[];
- }
- namespace LinkedList {
- class Item implements ListItem {
- list: LinkedList | null;
- next: ListItem;
- prev: ListItem;
- constructor ();
- append (item: ListItem): ListItem;
- detach (): boolean;
- prepend (item: ListItem): ListItem;
- }
- }
- }
Add Comment
Please, Sign In to add comment