summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js
blob: 7f9b224684df75388b91a4c89ec43dd8d958a0e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var __extends = this && this.t || function() {
    var extendStatics = function(t, n) {
        extendStatics = Object.setPrototypeOf || {
            __proto__: []
        } instanceof Array && function(t, n) {
            t.__proto__ = n;
        } || function(t, n) {
            for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) t[i] = n[i];
        };
        return extendStatics(t, n);
    };
    return function(t, n) {
        if (typeof n !== "function" && n !== null) throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
        extendStatics(t, n);
        function __() {
            this.constructor = t;
        }
        t.prototype = n === null ? Object.create(n) : (__.prototype = n.prototype, new __);
    };
}();

import { Base } from "../ContainerBase";

var Stack = function(t) {
    __extends(Stack, t);
    function Stack(n) {
        if (n === void 0) {
            n = [];
        }
        var i = t.call(this) || this;
        i.S = [];
        n.forEach((function(t) {
            return i.push(t);
        }));
        return i;
    }
    Stack.prototype.clear = function() {
        this.o = 0;
        this.S.length = 0;
    };
    Stack.prototype.push = function(t) {
        this.S.push(t);
        this.o += 1;
    };
    Stack.prototype.pop = function() {
        this.S.pop();
        if (this.o > 0) this.o -= 1;
    };
    Stack.prototype.top = function() {
        return this.S[this.o - 1];
    };
    return Stack;
}(Base);

export default Stack;