/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.collections.BinaryTree"],["require","dojox.collections._base"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.collections.BinaryTree"]){_4._hasResource["dojox.collections.BinaryTree"]=true;_4.provide("dojox.collections.BinaryTree");_4.require("dojox.collections._base");_6.collections.BinaryTree=function(_7){function _8(_9,_a,_b){this.value=_9||null;this.right=_a||null;this.left=_b||null;this.clone=function(){var c=new _8();if(this.value.value){c.value=this.value.clone();}else{c.value=this.value;}if(this.left!=null){c.left=this.left.clone();}if(this.right!=null){c.right=this.right.clone();}return c;};this.compare=function(n){if(this.value>n.value){return 1;}if(this.value<n.value){return -1;}return 0;};this.compareData=function(d){if(this.value>d){return 1;}if(this.value<d){return -1;}return 0;};};function _c(_d,a){if(_d){_c(_d.left,a);a.push(_d.value);_c(_d.right,a);}};function _e(_f,sep){var s="";if(_f){s=_f.value.toString()+sep;s+=_e(_f.left,sep);s+=_e(_f.right,sep);}return s;};function _10(_11,sep){var s="";if(_11){s=_10(_11.left,sep);s+=_11.value.toString()+sep;s+=_10(_11.right,sep);}return s;};function _12(_13,sep){var s="";if(_13){s=_12(_13.left,sep);s+=_12(_13.right,sep);s+=_13.value.toString()+sep;}return s;};function _14(_15,_16){if(!_15){return null;}var i=_15.compareData(_16);if(i==0){return _15;}if(i>0){return _14(_15.left,_16);}else{return _14(_15.right,_16);}};this.add=function(_17){var n=new _8(_17);var i;var _18=_19;var _1a=null;while(_18){i=_18.compare(n);if(i==0){return;}_1a=_18;if(i>0){_18=_18.left;}else{_18=_18.right;}}this.count++;if(!_1a){_19=n;}else{i=_1a.compare(n);if(i>0){_1a.left=n;}else{_1a.right=n;}}};this.clear=function(){_19=null;this.count=0;};this.clone=function(){var c=new _6.collections.BinaryTree();var itr=this.getIterator();while(!itr.atEnd()){c.add(itr.get());}return c;};this.contains=function(_1b){return this.search(_1b)!=null;};this.deleteData=function(_1c){var _1d=_19;var _1e=null;var i=_1d.compareData(_1c);while(i!=0&&_1d!=null){if(i>0){_1e=_1d;_1d=_1d.left;}else{if(i<0){_1e=_1d;_1d=_1d.right;}}i=_1d.compareData(_1c);}if(!_1d){return;}this.count--;if(!_1d.right){if(!_1e){_19=_1d.left;}else{i=_1e.compare(_1d);if(i>0){_1e.left=_1d.left;}else{if(i<0){_1e.right=_1d.left;}}}}else{if(!_1d.right.left){if(!_1e){_19=_1d.right;}else{i=_1e.compare(_1d);if(i>0){_1e.left=_1d.right;}else{if(i<0){_1e.right=_1d.right;}}}}else{var _1f=_1d.right.left;var _20=_1d.right;while(_1f.left!=null){_20=_1f;_1f=_1f.left;}_20.left=_1f.right;_1f.left=_1d.left;_1f.right=_1d.right;if(!_1e){_19=_1f;}else{i=_1e.compare(_1d);if(i>0){_1e.left=_1f;}else{if(i<0){_1e.right=_1f;}}}}}};this.getIterator=function(){var a=[];_c(_19,a);return new _6.collections.Iterator(a);};this.search=function(_21){return _14(_19,_21);};this.toString=function(_22,sep){if(!_22){_22=_6.collections.BinaryTree.TraversalMethods.Inorder;}if(!sep){sep=",";}var s="";switch(_22){case _6.collections.BinaryTree.TraversalMethods.Preorder:s=_e(_19,sep);break;case _6.collections.BinaryTree.TraversalMethods.Inorder:s=_10(_19,sep);break;case _6.collections.BinaryTree.TraversalMethods.Postorder:s=_12(_19,sep);break;}if(s.length==0){return "";}else{return s.substring(0,s.length-sep.length);}};this.count=0;var _19=this.root=null;if(_7){this.add(_7);}};_6.collections.BinaryTree.TraversalMethods={Preorder:1,Inorder:2,Postorder:3};}}};});