export class LinkedList { private first: LinkedListItem = null; private last: LinkedListItem = null; public add(item: T): void { let entry: LinkedListItem = { item: item, next: null }; if (this.last) { this.last.next = entry; } else { this.first = entry; } this.last = entry; } public remove(): T { let result = this.first; if (result) { this.first = result.next; if (!this.first) { this.last = null; } } return result.item; } public isEmpty(): boolean { return !this.first; } } class LinkedListItem { item: T; next: LinkedListItem; }