/*!
 * @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)};define(["require","exports","../../Compare","../../Types","../../Functions","./DictionaryBase","../Enumeration/EnumeratorBase","../LinkedNodeList"],function(e,t,r,n,o,u,i,a){"use strict";function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function l(e){return null===e?"null":e===c?"undefined":typeof e.toString===n["default"].FUNCTION?e.toString():Object.prototype.toString.call(e)}var 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=o["default"].Identity),e.call(this),this._compareSelector=t,this._count=0,this._entries=new a["default"],this._buckets={}}return __extends(t,e),t.prototype.setKV=function(e,t,n){var o,u=this,i=u._buckets,a=u._entries,f=u._compareSelector,y=f(e),d=l(y);if(s(i,d)){for(var h=r.areEqual,v=i[d],_=0;_<v.length;_++){var g=v[_];if(f(g.key)===y){if(!n)throw new Error("Key already exists.");var w=!h(g.value,t);return w&&(t===c?(a.removeNode(g),v.splice(_,1),v.length||delete i[d],--u._count):(o=new p(e,t),a.replace(g,o),v[_]=o),u._onValueUpdate(e,t,g.value)),w}}v.push(o=o||new p(e,t))}else{if(t===c){if(n)return!1;throw new Error("Cannot add 'undefined' value.")}i[d]=[o=new p(e,t)]}return++u._count,a.addNode(o),u._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 r=t._buckets,n=t._compareSelector,o=n(e),u=l(o);if(s(r,u))for(var i=r[u],a=0,p=i;a<p.length;a++){var f=p[a];if(n(f.key)===o)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 i["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}(u["default"]);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=f});
//# sourceMappingURL=Dictionary.js.map
