pokemon-showdown/tournaments/lib/closure-goog.structs.TreeNode-c8e0b2dcd892.min.js

22 lines
4.8 KiB
JavaScript

// Copyright 2010 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var b=exports;function h(a,c){var d=a.split("."),e=b;d[0]in e||!e.execScript||e.execScript("var "+d[0]);for(var f;d.length&&(f=d.shift());)d.length||void 0===c?e=e[f]?e[f]:e[f]={}:e[f]=c};function k(a,c){this.p=a;this.g=c}k.prototype.getKey=function(){return this.p};k.prototype.w=function(){return this.g};k.prototype.d=function(){return new k(this.p,this.g)};var l=Array.prototype,m=l.indexOf?function(a,c,d){return l.indexOf.call(a,c,d)}:function(a,c,d){d=null==d?0:0>d?Math.max(0,a.length+d):d;if("string"==typeof a)return"string"==typeof c&&1==c.length?a.indexOf(c,d):-1;for(;d<a.length;d++)if(d in a&&a[d]===c)return d;return-1},n=l.forEach?function(a,c,d){l.forEach.call(a,c,d)}:function(a,c,d){for(var e=a.length,f="string"==typeof a?a.split(""):a,g=0;g<e;g++)g in f&&c.call(d,f[g],g,a)};function p(a,c,d,e){l.splice.apply(a,q(arguments,1))}
function q(a,c,d){return 2>=arguments.length?l.slice.call(a,c):l.slice.call(a,c,d)};function r(a,c){k.call(this,a,c);this.a=this.c=null}(function(){function a(){}a.prototype=k.prototype;r.C=k.prototype;r.prototype=new a})();h("goog.structs.TreeNode",r);h("goog.structs.TreeNode.prototype.getKey",r.prototype.getKey);h("goog.structs.TreeNode.prototype.getValue",r.prototype.w);var s=[];r.prototype.d=function(){return new r(this.getKey(),this.g)};r.prototype.clone=r.prototype.d;r.prototype.j=function(){var a=this.d();this.e(function(c){a.h(c.j())});return a};r.prototype.deepClone=r.prototype.j;
r.prototype.getParent=function(){return this.c};r.prototype.getParent=r.prototype.getParent;r.prototype.o=function(){return!this.l()};r.prototype.isLeaf=r.prototype.o;r.prototype.A=function(){var a=this.getParent();return Boolean(a&&this==a.b()[a.b().length-1])};r.prototype.isLastChild=r.prototype.A;r.prototype.b=function(){return this.a||s};r.prototype.getChildren=r.prototype.b;r.prototype.u=function(a){return this.b()[a]||null};r.prototype.getChildAt=r.prototype.u;r.prototype.l=function(){return this.b().length};
r.prototype.getChildCount=r.prototype.l;r.prototype.f=function(){for(var a=0,c=this;c.getParent();)a++,c=c.getParent();return a};r.prototype.getDepth=r.prototype.f;r.prototype.t=function(){for(var a=[],c=this.getParent();c;)a.push(c),c=c.getParent();return a};r.prototype.getAncestors=r.prototype.t;r.prototype.v=function(){for(var a=this;a.getParent();)a=a.getParent();return a};r.prototype.getRoot=r.prototype.v;
r.prototype.n=function(){var a=[];this.e(function(c){a.push(c.getKey());c.o()||a.push(c.n())});return a};r.prototype.getSubtreeKeys=r.prototype.n;r.prototype.contains=function(a){do a=a.getParent();while(a&&a!=this);return Boolean(a)};r.prototype.contains=r.prototype.contains;r.findCommonAncestor=function(a){var c=arguments[0];if(!c)return null;for(var d=c.f(),e=1;e<arguments.length;e++)for(var f=arguments[e],g=f.f();f!=c;)g<=d&&(c=c.getParent(),d--),g>d&&(f=f.getParent(),g--);return c};
r.prototype.m=function(a){if(this.getKey()==a)return this;for(var c=this.b(),d=0;d<c.length;d++){var e=c[d].m(a);if(e)return e}return null};r.prototype.getNodeByKey=r.prototype.m;r.prototype.e=function(a,c){n(this.b(),a,c)};r.prototype.forEachChild=r.prototype.e;r.prototype.k=function(a,c){n(this.b(),function(d){a.call(c,d);d.k(a,c)})};r.prototype.forEachDescendant=r.prototype.k;r.prototype.s=function(a,c){!1!==a.call(c,this)&&n(this.b(),function(d){d.s(a,c)})};r.prototype.traverse=r.prototype.s;
r.prototype.h=function(a){this.i(a,this.a?this.a.length:0)};r.prototype.addChild=r.prototype.h;r.prototype.i=function(a,c){a.c=this;this.a=this.a||[];p(this.a,c,0,a)};r.prototype.addChildAt=r.prototype.i;r.prototype.r=function(a,c){var d=this.b(),e=d[c];e.c=null;d[c]=a;a.c=this;return e};r.prototype.replaceChildAt=r.prototype.r;r.prototype.replaceChild=function(a,c){return this.r(a,m(this.b(),c))};r.prototype.replaceChild=r.prototype.replaceChild;
r.prototype.q=function(a){var c=this.a&&this.a[a];return c?(c.c=null,l.splice.call(this.a,a,1),0==this.a.length&&delete this.a,c):null};r.prototype.removeChildAt=r.prototype.q;r.prototype.removeChild=function(a){return this.q(m(this.b(),a))};r.prototype.removeChild=r.prototype.removeChild;r.prototype.B=function(){this.a&&n(this.a,function(a){a.c=null});delete this.a};r.prototype.removeChildren=r.prototype.B;