1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | var LinkedList = (function () {
|
10 | function LinkedList() {
|
11 | this.first = null;
|
12 | this.last = null;
|
13 | }
|
14 | LinkedList.prototype.add = function (item) {
|
15 | var entry = {
|
16 | item: item,
|
17 | next: null
|
18 | };
|
19 | if (this.last) {
|
20 | this.last.next = entry;
|
21 | }
|
22 | else {
|
23 | this.first = entry;
|
24 | }
|
25 | this.last = entry;
|
26 | };
|
27 | LinkedList.prototype.remove = function () {
|
28 | var result = this.first;
|
29 | if (result) {
|
30 | this.first = result.next;
|
31 | if (!this.first) {
|
32 | this.last = null;
|
33 | }
|
34 | }
|
35 | return result.item;
|
36 | };
|
37 | LinkedList.prototype.isEmpty = function () {
|
38 | return !this.first;
|
39 | };
|
40 | return LinkedList;
|
41 | }());
|
42 | exports.LinkedList = LinkedList;
|
43 | var LinkedListItem = (function () {
|
44 | function LinkedListItem() {
|
45 | }
|
46 | return LinkedListItem;
|
47 | }());
|