/*!
 * @author electricessence / https://github.com/electricessence/
 * Original: http://linqjs.codeplex.com/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
var __extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)};!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","../../Compare","../../Types","../../Functions","./DictionaryBase","../Enumeration/EnumeratorBase","../LinkedNodeList"],e)}(function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function n(e){return null===e?"null":e===c?"undefined":typeof e.toString===u["default"].FUNCTION?e.toString():Object.prototype.toString.call(e)}var o=e("../../Compare"),u=e("../../Types"),i=e("../../Functions"),a=e("./DictionaryBase"),s=e("../Enumeration/EnumeratorBase"),l=e("../LinkedNodeList"),c=void 0,p=function(){function e(e,t,r,n){this.key=e,this.value=t,this.previous=r,this.next=n}return e}(),f=function(e){function t(t){void 0===t&&(t=i["default"].Identity),e.call(this),this._compareSelector=t,this._count=0,this._entries=new l["default"],this._buckets={}}return __extends(t,e),t.prototype.setKV=function(e,t,u){var i,a=this,s=a._buckets,l=a._entries,f=a._compareSelector,d=f(e),y=n(d);if(r(s,y)){for(var h=o.areEqual,v=s[y],_=0;_<v.length;_++){var m=v[_];if(f(m.key)===d){if(!u)throw new Error("Key already exists.");var g=!h(m.value,t);return g&&(t===c?(l.removeNode(m),v.splice(_,1),v.length||delete s[y],--a._count):(i=new p(e,t),l.replace(m,i),v[_]=i),a._onValueUpdate(e,t,m.value)),g}}v.push(i=i||new p(e,t))}else{if(t===c){if(u)return!1;throw new Error("Cannot add 'undefined' value.")}s[y]=[i=new p(e,t)]}return++a._count,l.addNode(i),a._onValueUpdate(e,t,void 0),!0},t.prototype.addByKeyValue=function(e,t){this.setKV(e,t,!1)},t.prototype._getEntry=function(e){var t=this;if(null!==e&&e!==c&&t._count){var o=t._buckets,u=t._compareSelector,i=u(e),a=n(i);if(r(o,a))for(var s=o[a],l=0,p=s;l<p.length;l++){var f=p[l];if(u(f.key)===i)return f}}return null},t.prototype.getValue=function(e){var t=this._getEntry(e);return t?t.value:c},t.prototype.setValue=function(e,t){return this.setKV(e,t,!0)},t.prototype.clear=function(){var t=this,r=t._buckets,n=e.prototype.clear.call(this);t._count=0;for(var o in r)r.hasOwnProperty(o)&&delete r[o];return t._entries.clear(),n},t.prototype.getCount=function(){return this._count},t.prototype.getEnumerator=function(){var e,t=this;return new s["default"](function(){e=t._entries.first},function(t){if(null!=e){var r={key:e.key,value:e.value};return e=e.next,t.yieldReturn(r)}return t.yieldBreak()})},t.prototype.getKeys=function(){for(var e=this,t=[],r=e._entries.first;r;)t.push(r.key),r=r.next;return t},t.prototype.getValues=function(){for(var e=this,t=[],r=e._entries.first;r;)t.push(r.value),r=r.next;return t},t}(a["default"]);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=f});
//# sourceMappingURL=Dictionary.js.map
