/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { List$1 } from "./List$1";
import { Dictionary$2 } from "./Dictionary$2";
import { Base, Number_$type, Boolean_$type, markType } from "./type";
var FastIterationDictionary$2 = /** @class */ (function (_super) {
    tslib_1.__extends(FastIterationDictionary$2, _super);
    function FastIterationDictionary$2($tKey, $tValue, a) {
        var _rest = [];
        for (var _i = 3; _i < arguments.length; _i++) {
            _rest[_i - 3] = arguments[_i];
        }
        var _this = _super.call(this) || this;
        _this.$tKey = null;
        _this.$tValue = null;
        _this.h = null;
        _this.l = null;
        _this.n = null;
        _this.m = null;
        _this.i = null;
        _this.c = false;
        _this.$tKey = $tKey;
        _this.$tValue = $tValue;
        _this.$type = _this.$type.specialize(_this.$tKey, _this.$tValue);
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = [null];
                    {
                        var e = c[0];
                        _this.h = new Dictionary$2(_this.$tKey, _this.$tValue, 2, e);
                        _this.l = new List$1(_this.$tKey, 0);
                        _this.n = new List$1(_this.$tValue, 0);
                        _this.i = new Dictionary$2(_this.$tKey, Number_$type, 0);
                        _this.m = new List$1(Boolean_$type, 0);
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    _this.h = new Dictionary$2(_this.$tKey, _this.$tValue, 2, c);
                    _this.l = new List$1(_this.$tKey, 0);
                    _this.n = new List$1(_this.$tValue, 0);
                    _this.i = new Dictionary$2(_this.$tKey, Number_$type, 0);
                    _this.m = new List$1(Boolean_$type, 0);
                }
                break;
        }
        return _this;
    }
    FastIterationDictionary$2.prototype.p = function (a, b) {
        this.h.addItem(a, b);
        this.l.add(a);
        this.n.add(b);
        this.i.addItem(a, this.l.count - 1);
        this.m.add(false);
    };
    FastIterationDictionary$2.prototype.r = function () {
        this.h.clear();
        this.l.clear();
        this.n.clear();
        this.i.clear();
        this.m.clear();
    };
    FastIterationDictionary$2.prototype.d = function (a) {
        return this.h.containsKey(a);
    };
    Object.defineProperty(FastIterationDictionary$2.prototype, "o", {
        get: function () {
            return this.h.count;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastIterationDictionary$2.prototype, "j", {
        get: function () {
            return this.h.keys;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastIterationDictionary$2.prototype, "f", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
            if (this.m.count > (this.i.count * 3)) {
                this.q();
            }
        },
        enumerable: true,
        configurable: true
    });
    FastIterationDictionary$2.prototype.e = function (a) {
        var b = this.h.removeItem(a);
        if (b) {
            var c = this.i.item(a);
            this.m._inner[c] = true;
            this.i.removeItem(a);
            if (this.m.count > (this.i.count * 3)) {
                this.q();
            }
            return b;
        }
        return b;
    };
    FastIterationDictionary$2.prototype.q = function () {
        if (this.f) {
            return;
        }
        var a = this.m.count;
        var b = 0;
        var c = false;
        for (var d = 0; d < a; d++) {
            if (this.m._inner[d]) {
                this.l.removeAt(d);
                this.n.removeAt(d);
                this.m.removeAt(d);
                d--;
                a--;
                c = true;
            }
            else {
                if (c) {
                    this.i.removeItem(this.l._inner[d]);
                    this.i.addItem(this.l._inner[d], b);
                }
                b++;
            }
        }
    };
    FastIterationDictionary$2.prototype.g = function (a, b) {
        var _this = this;
        return {
            ret: ((function () { var c = _this.h.tryGetValue(a, b); b = c.p1; return c.ret; })()),
            p1: b
        };
    };
    FastIterationDictionary$2.prototype.b = function (a) {
        return this.h.f(a);
    };
    Object.defineProperty(FastIterationDictionary$2.prototype, "k", {
        get: function () {
            return this.h.values;
        },
        enumerable: true,
        configurable: true
    });
    FastIterationDictionary$2.prototype.item = function (a, b) {
        if (arguments.length === 2) {
            if (!this.d(a)) {
                this.p(a, b);
            }
            else {
                this.h.item(a, b);
                var c = this.i.item(a);
                this.n._inner[c] = b;
                this.m._inner[c] = false;
            }
            return b;
        }
        else {
            return this.h.item(a);
        }
    };
    FastIterationDictionary$2.$t = markType(FastIterationDictionary$2, 'FastIterationDictionary$2');
    return FastIterationDictionary$2;
}(Base));
export { FastIterationDictionary$2 };
//# sourceMappingURL=FastIterationDictionary$2.js.map