You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1109 lines
27 KiB
1109 lines
27 KiB
// Generated by Haxe 4.0.0+ef18b627e
|
|
var serve = {};
|
|
(function ($hx_exports, $global) {
|
|
"use strict";
|
|
$hx_exports["jiaoyisuo"] = $hx_exports["jiaoyisuo"] || {};
|
|
class HxOverrides {
|
|
static iter(a) {
|
|
return {
|
|
cur: 0,
|
|
arr: a,
|
|
hasNext: function () {
|
|
return this.cur < this.arr.length;
|
|
},
|
|
next: function () {
|
|
return this.arr[this.cur++];
|
|
}
|
|
};
|
|
}
|
|
}
|
|
HxOverrides.__name__ = true;
|
|
class MainBoCai {
|
|
constructor() {}
|
|
static main2() {}
|
|
static main() {
|
|
// MainBoCai.genJson(100);
|
|
}
|
|
static genJson(total) {
|
|
var data = jiaoyisuo_JYSHelper.makeTestData(total);
|
|
var tree = jiaoyisuo_JYSHelper.makeTree(data, 0);
|
|
var json = jiaoyisuo_JYSHelper.makeJson(tree, data);
|
|
console.log("src/MainBoCai.hx:39:", json);
|
|
return json;
|
|
}
|
|
}
|
|
$hx_exports["MainBoCai"] = MainBoCai;
|
|
MainBoCai.__name__ = true;
|
|
Object.assign(MainBoCai.prototype, {
|
|
__class__: MainBoCai
|
|
});
|
|
Math.__name__ = true;
|
|
class Std {
|
|
static string(s) {
|
|
return js_Boot.__string_rec(s, "");
|
|
}
|
|
}
|
|
Std.__name__ = true;
|
|
class _$UInt_UInt_$Impl_$ {
|
|
static toFloat(this1) {
|
|
var int = this1;
|
|
if (int < 0) {
|
|
return 4294967296.0 + int;
|
|
} else {
|
|
return int + 0.0;
|
|
}
|
|
}
|
|
}
|
|
_$UInt_UInt_$Impl_$.__name__ = true;
|
|
class haxe_IMap {}
|
|
haxe_IMap.__name__ = true;
|
|
haxe_IMap.__isInterface__ = true;
|
|
class haxe_ds_IntMap {
|
|
constructor() {
|
|
this.h = {};
|
|
}
|
|
keys() {
|
|
var a = [];
|
|
for (var key in this.h) this.h.hasOwnProperty(key) ? a.push(key | 0) : null;
|
|
return HxOverrides.iter(a);
|
|
}
|
|
iterator() {
|
|
return {
|
|
ref: this.h,
|
|
it: this.keys(),
|
|
hasNext: function () {
|
|
return this.it.hasNext();
|
|
},
|
|
next: function () {
|
|
var i = this.it.next();
|
|
return this.ref[i];
|
|
}
|
|
};
|
|
}
|
|
}
|
|
haxe_ds_IntMap.__name__ = true;
|
|
haxe_ds_IntMap.__interfaces__ = [haxe_IMap];
|
|
Object.assign(haxe_ds_IntMap.prototype, {
|
|
__class__: haxe_ds_IntMap
|
|
});
|
|
class haxe_ds_StringMap {
|
|
constructor() {
|
|
this.h = {};
|
|
}
|
|
setReserved(key, value) {
|
|
if (this.rh == null) {
|
|
this.rh = {};
|
|
}
|
|
this.rh["$" + key] = value;
|
|
}
|
|
getReserved(key) {
|
|
if (this.rh == null) {
|
|
return null;
|
|
} else {
|
|
return this.rh["$" + key];
|
|
}
|
|
}
|
|
}
|
|
haxe_ds_StringMap.__name__ = true;
|
|
haxe_ds_StringMap.__interfaces__ = [haxe_IMap];
|
|
Object.assign(haxe_ds_StringMap.prototype, {
|
|
__class__: haxe_ds_StringMap
|
|
});
|
|
class jiaoyisuo_JYSHelper {
|
|
static makeTestData(total) {
|
|
var arr = new haxe_ds_IntMap();
|
|
var tt = [100, 200, 500];
|
|
var _g = [];
|
|
var _g1 = 0;
|
|
var _g2 = Math.floor(101 * Math.random());
|
|
while (_g1 < _g2) {
|
|
var i = _g1++;
|
|
_g.push(tt[Math.floor((tt.length - 1 + 1) * Math.random())]);
|
|
}
|
|
var node = {
|
|
id: 0,
|
|
parent: -1,
|
|
chargeMoney: _g,
|
|
money: (1 + Math.floor(10 * Math.random())) * 1000,
|
|
loseMoeny: (1 + Math.floor(10 * Math.random())) * 10,
|
|
jiCha: (1 + Math.floor(3 * Math.random())) * 10 / 100,
|
|
sum: 0
|
|
};
|
|
arr.h[0] = node;
|
|
var index = 0;
|
|
var parentArray = [];
|
|
parentArray.push(0);
|
|
var _g3 = 1;
|
|
var _g4 = total;
|
|
while (_g3 < _g4) {
|
|
var i1 = _g3++;
|
|
var id = index + 1;
|
|
var parentID = parentArray[Math.floor((parentArray.length - 1 + 1) * Math.random())];
|
|
parentArray.push(id);
|
|
var _g31 = [];
|
|
var _g41 = 0;
|
|
var _g5 = 1 + Math.floor(10 * Math.random());
|
|
while (_g41 < _g5) {
|
|
var i2 = _g41++;
|
|
_g31.push(tt[Math.floor((tt.length - 1 + 1) * Math.random())]);
|
|
}
|
|
var mode = {
|
|
id: id,
|
|
parent: parentID,
|
|
chargeMoney: _g31,
|
|
money: (1 + Math.floor(10 * Math.random())) * 1000,
|
|
loseMoeny: (1 + Math.floor(10 * Math.random())) * 10,
|
|
jiCha: (1 + Math.floor(3 * Math.random())) * 10 / 100,
|
|
sum: 0
|
|
};
|
|
arr.h[id] = mode;
|
|
++index;
|
|
}
|
|
return arr;
|
|
}
|
|
static makeTree(arr, id) {
|
|
if (id == null) {
|
|
id = 0;
|
|
}
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:75:", "开始构建树" + Std.string(id == null ? null : _$UInt_UInt_$Impl_$.toFloat(id)));
|
|
var currentNode = arr.h[id];
|
|
var root = arr.h[id];
|
|
var can = new haxe_ds_IntMap();
|
|
var e = arr.iterator();
|
|
while (e.hasNext()) {
|
|
var e1 = e.next();
|
|
var loop = true;
|
|
var current = e1;
|
|
if (!can.h.hasOwnProperty(current.id)) {
|
|
while (current.parent != -1 && loop)
|
|
if (current.parent == root.id) {
|
|
can.h[current.id] = current;
|
|
loop = false;
|
|
if (current.id != e1.id) {
|
|
current = e1;
|
|
while (current.parent != -1) {
|
|
if (!can.h.hasOwnProperty(current.parent)) {
|
|
if (current.parent == root.id) {
|
|
break;
|
|
}
|
|
var v = arr.h[current.parent];
|
|
can.h[current.parent] = v;
|
|
}
|
|
current = arr.h[current.parent];
|
|
}
|
|
}
|
|
} else {
|
|
current = arr.h[current.parent];
|
|
}
|
|
}
|
|
}
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:113:", "构建树--------------------------");
|
|
var treeRoot = new polygonal_ds_TreeNode(id);
|
|
arr.h[id].node = treeRoot;
|
|
var rootParentID = arr.h[id].parent;
|
|
var e2 = can.iterator();
|
|
while (e2.hasNext()) {
|
|
var e3 = e2.next();
|
|
var node = arr.h[e3.id].node;
|
|
if (e3.id != id && node == null) {
|
|
node = new polygonal_ds_TreeNode(e3.id);
|
|
arr.h[e3.id].node = node;
|
|
}
|
|
if (e3.parent != rootParentID) {
|
|
if (arr.h.hasOwnProperty(e3.parent)) {
|
|
var parentNode = arr.h[e3.parent].node;
|
|
if (parentNode == null) {
|
|
parentNode = new polygonal_ds_TreeNode(e3.parent);
|
|
arr.h[e3.parent].node = parentNode;
|
|
}
|
|
if (parentNode.val == e3.parent) {
|
|
parentNode.appendNode(node);
|
|
} else {
|
|
if (treeRoot.find(node.val) == null) {
|
|
treeRoot.appendNode(node);
|
|
}
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:142:", " fter id=" + e3.id + " parent=" + e3.parent + " node=" + node.val + " nodeparent=" + arr.h[e3.parent].node.val);
|
|
}
|
|
} else {
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:145:", "fucking...沒有?" + e3.parent);
|
|
}
|
|
}
|
|
}
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:150:", treeRoot.toString());
|
|
return treeRoot;
|
|
}
|
|
static makeJson(root, arr) {
|
|
var node = arr.h[root.val];
|
|
var jsonRoot = {
|
|
name: node.id + "",
|
|
value: node.money + "",
|
|
children: [],
|
|
collapsed: false
|
|
};
|
|
var map = new haxe_ds_StringMap();
|
|
var k = jsonRoot.name;
|
|
if (__map_reserved[k] != null) {
|
|
map.setReserved(k, jsonRoot);
|
|
} else {
|
|
map.h[k] = jsonRoot;
|
|
}
|
|
root.preorder(function (node1, preflight, userData) {
|
|
if (node1.parent != null) {
|
|
var mNode = arr.h[node1.val];
|
|
var currentNode = {};
|
|
if (node1.children != null) {
|
|
var k1 = mNode.id + "";
|
|
var v = {
|
|
name: mNode.id + "",
|
|
value: mNode.money + "",
|
|
children: []
|
|
};
|
|
if (__map_reserved[k1] != null) {
|
|
map.setReserved(k1, v);
|
|
} else {
|
|
map.h[k1] = v;
|
|
}
|
|
currentNode = v;
|
|
} else {
|
|
currentNode = {
|
|
name: mNode.id + "",
|
|
value: mNode.money + ""
|
|
};
|
|
}
|
|
var key = mNode.parent + "";
|
|
(__map_reserved[key] != null ? map.getReserved(key) : map.h[key]).children.push(currentNode);
|
|
}
|
|
return true;
|
|
}, null, false, true);
|
|
var content = JSON.stringify(jsonRoot);
|
|
return content;
|
|
}
|
|
static caleDynamicIncomeFromChild(root, arr) {
|
|
var persents_0 = 0.05;
|
|
var persents_1 = 0.08;
|
|
var persents_2 = 0.12;
|
|
var persents_3 = 0.16;
|
|
var persents_4 = 0.2;
|
|
var scores_0 = 2;
|
|
var scores_1 = 12;
|
|
var scores_2 = 30;
|
|
var scores_3 = 60;
|
|
var scores_4 = 120;
|
|
var rootClone = root.clone();
|
|
var childs = rootClone.childIterator();
|
|
var nodeSumArray = [];
|
|
var e = childs;
|
|
while (e.hasNext()) {
|
|
var e1 = e.next();
|
|
var currentNode = rootClone.find(e1);
|
|
var sum = [0];
|
|
currentNode.preorder((function (sum1) {
|
|
return function (node, preflight, userData) {
|
|
sum1[0] += arr.h[node.val].money;
|
|
return true;
|
|
};
|
|
})(sum), null, false, true);
|
|
nodeSumArray.push({
|
|
node: e1,
|
|
sum: sum[0]
|
|
});
|
|
}
|
|
nodeSumArray.sort(function (a, b) {
|
|
if (a.sum > b.sum) {
|
|
return -1;
|
|
} else {
|
|
return 1;
|
|
}
|
|
});
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:226:", "去掉极大值-----------" + nodeSumArray[0].node + "所有节点");
|
|
if (nodeSumArray.length > 1) {
|
|
var nodeU = rootClone.find(nodeSumArray[0].node);
|
|
nodeU.unlink();
|
|
} else {
|
|
console.log("src/jiaoyisuo/JYSHelper.hx:233:", "只有1个节点 不裁剪");
|
|
}
|
|
var sum2 = 0;
|
|
var sum21 = 0;
|
|
rootClone.preorder(function (node1, preflight1, userData1) {
|
|
if (node1.depth() > 0) {
|
|
sum2 += arr.h[node1.val].money;
|
|
sum21 += arr.h[node1.val].staitcIncome;
|
|
}
|
|
return true;
|
|
}, null, false, true);
|
|
return arr;
|
|
}
|
|
static caleRecommandIncome(id, root, arr, maxLevel) {
|
|
if (maxLevel == null) {
|
|
maxLevel = 8;
|
|
}
|
|
var node = arr.h[id];
|
|
var total = node.money;
|
|
var rootID = root.parent.val;
|
|
var currentNode = root.find(id);
|
|
var level = 0;
|
|
while (currentNode.parent != null)
|
|
if (level < maxLevel) {
|
|
arr.h[currentNode.parent.val].recommendMoney += total * 5 / 100 * 10 / 100;
|
|
currentNode = currentNode.parent;
|
|
}
|
|
}
|
|
static caleStaticIncome(target, win) {
|
|
if (win) {
|
|
target.staitcIncome = target.gameUSDT * (0.1 + 0.19999999999999998 * Math.random());
|
|
} else {
|
|
target.staitcIncome = target.gameUSDT * 5 / 100;
|
|
}
|
|
}
|
|
static caleTearmIncome() {}
|
|
static getlimtIncome() {}
|
|
static getShareIncome() {}
|
|
static freezingMoney() {}
|
|
static getDividendEveryData() {}
|
|
static initData() {}
|
|
static getMNode() {}
|
|
}
|
|
$hx_exports["jiaoyisuo"]["JYSHelper"] = jiaoyisuo_JYSHelper;
|
|
jiaoyisuo_JYSHelper.__name__ = true;
|
|
class js__$Boot_HaxeError extends Error {
|
|
constructor(val) {
|
|
super();
|
|
this.val = val;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, js__$Boot_HaxeError);
|
|
}
|
|
}
|
|
}
|
|
js__$Boot_HaxeError.__name__ = true;
|
|
js__$Boot_HaxeError.__super__ = Error;
|
|
Object.assign(js__$Boot_HaxeError.prototype, {
|
|
__class__: js__$Boot_HaxeError
|
|
});
|
|
class js_Boot {
|
|
static getClass(o) {
|
|
if (o == null) {
|
|
return null;
|
|
} else if (((o) instanceof Array)) {
|
|
return Array;
|
|
} else {
|
|
var cl = o.__class__;
|
|
if (cl != null) {
|
|
return cl;
|
|
}
|
|
var name = js_Boot.__nativeClassName(o);
|
|
if (name != null) {
|
|
return js_Boot.__resolveNativeClass(name);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
static __string_rec(o, s) {
|
|
if (o == null) {
|
|
return "null";
|
|
}
|
|
if (s.length >= 5) {
|
|
return "<...>";
|
|
}
|
|
var t = typeof (o);
|
|
if (t == "function" && (o.__name__ || o.__ename__)) {
|
|
t = "object";
|
|
}
|
|
switch (t) {
|
|
case "function":
|
|
return "<function>";
|
|
case "object":
|
|
if (((o) instanceof Array)) {
|
|
var str = "[";
|
|
s += "\t";
|
|
var _g3 = 0;
|
|
var _g11 = o.length;
|
|
while (_g3 < _g11) {
|
|
var i = _g3++;
|
|
str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i], s);
|
|
}
|
|
str += "]";
|
|
return str;
|
|
}
|
|
var tostr;
|
|
try {
|
|
tostr = o.toString;
|
|
} catch (e1) {
|
|
var e2 = ((e1) instanceof js__$Boot_HaxeError) ? e1.val : e1;
|
|
return "???";
|
|
}
|
|
if (tostr != null && tostr != Object.toString && typeof (tostr) == "function") {
|
|
var s2 = o.toString();
|
|
if (s2 != "[object Object]") {
|
|
return s2;
|
|
}
|
|
}
|
|
var str1 = "{\n";
|
|
s += "\t";
|
|
var hasp = o.hasOwnProperty != null;
|
|
var k = null;
|
|
for (k in o) {
|
|
if (hasp && !o.hasOwnProperty(k)) {
|
|
continue;
|
|
}
|
|
if (k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
|
|
continue;
|
|
}
|
|
if (str1.length != 2) {
|
|
str1 += ", \n";
|
|
}
|
|
str1 += s + k + " : " + js_Boot.__string_rec(o[k], s);
|
|
}
|
|
s = s.substring(1);
|
|
str1 += "\n" + s + "}";
|
|
return str1;
|
|
case "string":
|
|
return o;
|
|
default:
|
|
return String(o);
|
|
}
|
|
}
|
|
static __interfLoop(cc, cl) {
|
|
if (cc == null) {
|
|
return false;
|
|
}
|
|
if (cc == cl) {
|
|
return true;
|
|
}
|
|
if (Object.prototype.hasOwnProperty.call(cc, "__interfaces__")) {
|
|
var intf = cc.__interfaces__;
|
|
var _g = 0;
|
|
var _g1 = intf.length;
|
|
while (_g < _g1) {
|
|
var i = _g++;
|
|
var i1 = intf[i];
|
|
if (i1 == cl || js_Boot.__interfLoop(i1, cl)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return js_Boot.__interfLoop(cc.__super__, cl);
|
|
}
|
|
static __instanceof(o, cl) {
|
|
if (cl == null) {
|
|
return false;
|
|
}
|
|
switch (cl) {
|
|
case Array:
|
|
return ((o) instanceof Array);
|
|
case Bool:
|
|
return typeof (o) == "boolean";
|
|
case Dynamic:
|
|
return o != null;
|
|
case Float:
|
|
return typeof (o) == "number";
|
|
case Int:
|
|
if (typeof (o) == "number") {
|
|
return ((o | 0) === o);
|
|
} else {
|
|
return false;
|
|
}
|
|
break;
|
|
case String:
|
|
return typeof (o) == "string";
|
|
default:
|
|
if (o != null) {
|
|
if (typeof (cl) == "function") {
|
|
if (js_Boot.__downcastCheck(o, cl)) {
|
|
return true;
|
|
}
|
|
} else if (typeof (cl) == "object" && js_Boot.__isNativeObj(cl)) {
|
|
if (((o) instanceof cl)) {
|
|
return true;
|
|
}
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
if (cl == Class ? o.__name__ != null : false) {
|
|
return true;
|
|
}
|
|
if (cl == Enum ? o.__ename__ != null : false) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
static __downcastCheck(o, cl) {
|
|
if (!((o) instanceof cl)) {
|
|
if (cl.__isInterface__) {
|
|
return js_Boot.__interfLoop(js_Boot.getClass(o), cl);
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
static __cast(o, t) {
|
|
if (o == null || js_Boot.__instanceof(o, t)) {
|
|
return o;
|
|
} else {
|
|
throw new js__$Boot_HaxeError("Cannot cast " + Std.string(o) + " to " + Std.string(t));
|
|
}
|
|
}
|
|
static __nativeClassName(o) {
|
|
var name = js_Boot.__toStr.call(o).slice(8, -1);
|
|
if (name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
|
|
return null;
|
|
}
|
|
return name;
|
|
}
|
|
static __isNativeObj(o) {
|
|
return js_Boot.__nativeClassName(o) != null;
|
|
}
|
|
static __resolveNativeClass(name) {
|
|
return $global[name];
|
|
}
|
|
}
|
|
js_Boot.__name__ = true;
|
|
class polygonal_ds_Hashable {}
|
|
polygonal_ds_Hashable.__name__ = true;
|
|
polygonal_ds_Hashable.__isInterface__ = true;
|
|
class polygonal_ds_Collection {}
|
|
polygonal_ds_Collection.__name__ = true;
|
|
polygonal_ds_Collection.__isInterface__ = true;
|
|
polygonal_ds_Collection.__interfaces__ = [polygonal_ds_Hashable];
|
|
Object.assign(polygonal_ds_Collection.prototype, {
|
|
__class__: polygonal_ds_Collection
|
|
});
|
|
class polygonal_ds_Itr {}
|
|
polygonal_ds_Itr.__name__ = true;
|
|
polygonal_ds_Itr.__isInterface__ = true;
|
|
Object.assign(polygonal_ds_Itr.prototype, {
|
|
__class__: polygonal_ds_Itr
|
|
});
|
|
class polygonal_ds_Cloneable {}
|
|
polygonal_ds_Cloneable.__name__ = true;
|
|
polygonal_ds_Cloneable.__isInterface__ = true;
|
|
Object.assign(polygonal_ds_Cloneable.prototype, {
|
|
__class__: polygonal_ds_Cloneable
|
|
});
|
|
class polygonal_ds_TreeNode {
|
|
constructor(val, parent) {
|
|
this.mExtraInfo = 0;
|
|
this.val = val;
|
|
this.parent = parent;
|
|
this.children = null;
|
|
this.prev = null;
|
|
this.next = null;
|
|
this.mTail = null;
|
|
this.mNextInStack = null;
|
|
this.mPrevInStack = null;
|
|
if (this.parent != null) {
|
|
parent.mExtraInfo = parent.mExtraInfo & 65535 | (parent.mExtraInfo >>> 16) + 1 << 16;
|
|
if (parent.children != null) {
|
|
var tail = parent.mTail;
|
|
tail.next = this;
|
|
this.prev = tail;
|
|
this.next = null;
|
|
} else {
|
|
parent.children = this;
|
|
}
|
|
parent.mTail = this;
|
|
}
|
|
}
|
|
depth() {
|
|
if (this.parent == null) {
|
|
return 0;
|
|
} else {
|
|
var node = this;
|
|
var c = 0;
|
|
while (node.parent != null) {
|
|
++c;
|
|
node = node.parent;
|
|
}
|
|
return c;
|
|
}
|
|
}
|
|
height() {
|
|
var h = 0;
|
|
var node = this.children;
|
|
while (node != null) {
|
|
var y = node.height();
|
|
h = h > y ? h : y;
|
|
node = node.next;
|
|
}
|
|
return 1 + h;
|
|
}
|
|
unlink() {
|
|
if (this.parent != null) {
|
|
if (this.parent.children == this) {
|
|
this.parent.children = this.next;
|
|
}
|
|
if (this.parent.mTail == this) {
|
|
this.parent.mTail = this.prev;
|
|
}
|
|
var _this = this.parent;
|
|
_this.mExtraInfo = _this.mExtraInfo & 65535 | (_this.mExtraInfo >>> 16) - 1 << 16;
|
|
this.parent = null;
|
|
}
|
|
if (this.prev != null) {
|
|
this.prev.next = this.next;
|
|
}
|
|
if (this.next != null) {
|
|
this.next.prev = this.prev;
|
|
}
|
|
this.next = this.prev = null;
|
|
this.mNextInStack = null;
|
|
this.mPrevInStack = null;
|
|
return this;
|
|
}
|
|
appendNode(node) {
|
|
node.unlink();
|
|
node.parent = this;
|
|
this.mExtraInfo = this.mExtraInfo & 65535 | (this.mExtraInfo >>> 16) + 1 << 16;
|
|
if (this.children != null) {
|
|
this.mTail.next = node;
|
|
node.prev = this.mTail;
|
|
node.next = null;
|
|
this.mTail = node;
|
|
} else {
|
|
this.mTail = node;
|
|
this.children = node;
|
|
}
|
|
return this;
|
|
}
|
|
find(val) {
|
|
var top = this;
|
|
while (top != null) {
|
|
var node = top;
|
|
var top1 = top;
|
|
var t = top1;
|
|
top1 = top1.mPrevInStack;
|
|
if (top1 != null) {
|
|
top1.mNextInStack = null;
|
|
}
|
|
t.mPrevInStack = null;
|
|
top = top1;
|
|
if (node.val == val) {
|
|
return node;
|
|
}
|
|
var n = node.children;
|
|
if (n != null) {
|
|
var c = node.mTail;
|
|
while (c != null) {
|
|
if (top != null) {
|
|
top.mNextInStack = c;
|
|
c.mPrevInStack = top;
|
|
}
|
|
top = c;
|
|
c = c.prev;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
preorder($process, userData, preflight, iterative) {
|
|
if (iterative == null) {
|
|
iterative = false;
|
|
}
|
|
if (preflight == null) {
|
|
preflight = false;
|
|
}
|
|
if (this.parent == null && this.children == null) {
|
|
if ($process == null) {
|
|
var v = this.val;
|
|
if (preflight) {
|
|
if (v.visit(true, userData)) {
|
|
v.visit(false, userData);
|
|
}
|
|
} else {
|
|
v.visit(false, userData);
|
|
}
|
|
} else if (preflight) {
|
|
if ($process(this, true, userData)) {
|
|
$process(this, false, userData);
|
|
}
|
|
} else {
|
|
$process(this, false, userData);
|
|
}
|
|
return this;
|
|
}
|
|
if (iterative == false) {
|
|
if ($process == null) {
|
|
if (preflight) {
|
|
var v1 = this.val;
|
|
if (v1.visit(true, userData)) {
|
|
if (v1.visit(false, userData)) {
|
|
var child = this.children;
|
|
var hook;
|
|
while (child != null) {
|
|
hook = child.next;
|
|
if (!this.preOrderInternalVisitablePreflight(child, userData)) {
|
|
return this;
|
|
}
|
|
child = hook;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
var v2 = this.val;
|
|
if (v2.visit(false, userData)) {
|
|
var child1 = this.children;
|
|
var hook1;
|
|
while (child1 != null) {
|
|
hook1 = child1.next;
|
|
if (!this.preOrderInternalVisitable(child1, userData)) {
|
|
return this;
|
|
}
|
|
child1 = hook1;
|
|
}
|
|
}
|
|
}
|
|
} else if (preflight) {
|
|
if ($process(this, true, userData)) {
|
|
if ($process(this, false, userData)) {
|
|
var child2 = this.children;
|
|
var hook2;
|
|
while (child2 != null) {
|
|
hook2 = child2.next;
|
|
if (!this.preOrderInternalPreflight(child2, $process, userData)) {
|
|
return this;
|
|
}
|
|
child2 = hook2;
|
|
}
|
|
}
|
|
}
|
|
} else if ($process(this, false, userData)) {
|
|
var child3 = this.children;
|
|
var hook3;
|
|
while (child3 != null) {
|
|
hook3 = child3.next;
|
|
if (!this.preOrderInternal(child3, $process, userData)) {
|
|
return this;
|
|
}
|
|
child3 = hook3;
|
|
}
|
|
}
|
|
} else {
|
|
var top = this;
|
|
if ($process == null) {
|
|
if (preflight) {
|
|
while (top != null) {
|
|
var node = top;
|
|
var top1 = top;
|
|
var t = top1;
|
|
top1 = top1.mPrevInStack;
|
|
if (top1 != null) {
|
|
top1.mNextInStack = null;
|
|
}
|
|
t.mPrevInStack = null;
|
|
top = top1;
|
|
var v3 = node.val;
|
|
if (!v3.visit(true, userData)) {
|
|
continue;
|
|
}
|
|
if (!v3.visit(false, userData)) {
|
|
return this;
|
|
}
|
|
var n = node.children;
|
|
if (n != null) {
|
|
var c = node.mTail;
|
|
while (c != null) {
|
|
if (top != null) {
|
|
top.mNextInStack = c;
|
|
c.mPrevInStack = top;
|
|
}
|
|
top = c;
|
|
c = c.prev;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
while (top != null) {
|
|
var node1 = top;
|
|
var top2 = top;
|
|
var t1 = top2;
|
|
top2 = top2.mPrevInStack;
|
|
if (top2 != null) {
|
|
top2.mNextInStack = null;
|
|
}
|
|
t1.mPrevInStack = null;
|
|
top = top2;
|
|
var v4 = node1.val;
|
|
if (!v4.visit(false, userData)) {
|
|
return this;
|
|
}
|
|
var n1 = node1.children;
|
|
if (n1 != null) {
|
|
var c1 = node1.mTail;
|
|
while (c1 != null) {
|
|
if (top != null) {
|
|
top.mNextInStack = c1;
|
|
c1.mPrevInStack = top;
|
|
}
|
|
top = c1;
|
|
c1 = c1.prev;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (preflight) {
|
|
while (top != null) {
|
|
var node2 = top;
|
|
var top3 = top;
|
|
var t2 = top3;
|
|
top3 = top3.mPrevInStack;
|
|
if (top3 != null) {
|
|
top3.mNextInStack = null;
|
|
}
|
|
t2.mPrevInStack = null;
|
|
top = top3;
|
|
if (!$process(node2, true, userData)) {
|
|
continue;
|
|
}
|
|
if (!$process(node2, false, userData)) {
|
|
return this;
|
|
}
|
|
var n2 = node2.children;
|
|
if (n2 != null) {
|
|
var c2 = node2.mTail;
|
|
while (c2 != null) {
|
|
if (top != null) {
|
|
top.mNextInStack = c2;
|
|
c2.mPrevInStack = top;
|
|
}
|
|
top = c2;
|
|
c2 = c2.prev;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
while (top != null) {
|
|
var node3 = top;
|
|
var top4 = top;
|
|
var t3 = top4;
|
|
top4 = top4.mPrevInStack;
|
|
if (top4 != null) {
|
|
top4.mNextInStack = null;
|
|
}
|
|
t3.mPrevInStack = null;
|
|
top = top4;
|
|
if (!$process(node3, false, userData)) {
|
|
return this;
|
|
}
|
|
var n3 = node3.children;
|
|
if (n3 != null) {
|
|
var c3 = node3.mTail;
|
|
while (c3 != null) {
|
|
if (top != null) {
|
|
top.mNextInStack = c3;
|
|
c3.mPrevInStack = top;
|
|
}
|
|
top = c3;
|
|
c3 = c3.prev;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
toString() {
|
|
var b_b = "";
|
|
var _gthis = this;
|
|
b_b += Std.string("[ Tree size=" + this.get_size() + " depth=" + this.depth() + " height=" + this.height());
|
|
if (this.children == null) {
|
|
b_b += "\n";
|
|
b_b += " ";
|
|
b_b += Std.string(Std.string(this.val));
|
|
b_b += "\n";
|
|
b_b += "]";
|
|
return b_b;
|
|
}
|
|
b_b += "\n";
|
|
this.preorder(function (node, preflight, userData) {
|
|
var d = node.depth();
|
|
var _g = 0;
|
|
var _g1 = d;
|
|
while (_g < _g1) {
|
|
var i = _g++;
|
|
if (i == d - 1) {
|
|
b_b += " +--- ";
|
|
} else {
|
|
b_b += " | ";
|
|
}
|
|
}
|
|
if (node == _gthis) {
|
|
b_b += " ";
|
|
}
|
|
b_b += Std.string(Std.string(node.val) + "\n");
|
|
return true;
|
|
}, null);
|
|
b_b += "]";
|
|
return b_b;
|
|
}
|
|
childIterator() {
|
|
return new polygonal_ds_ChildTreeIterator(this);
|
|
}
|
|
preOrderInternal(node, $process, userData) {
|
|
if ($process(node, false, userData)) {
|
|
if (node.children != null) {
|
|
var walker = node.children;
|
|
while (walker != null) {
|
|
if (!this.preOrderInternal(walker, $process, userData)) {
|
|
return false;
|
|
}
|
|
walker = walker.next;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
preOrderInternalPreflight(node, $process, userData) {
|
|
if ($process(node, true, userData)) {
|
|
if ($process(node, false, userData)) {
|
|
if (node.children != null) {
|
|
var walker = node.children;
|
|
while (walker != null) {
|
|
if (!this.preOrderInternalPreflight(walker, $process, userData)) {
|
|
return false;
|
|
}
|
|
walker = walker.next;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
preOrderInternalVisitable(node, userData) {
|
|
var v = node.val;
|
|
if (v.visit(false, userData)) {
|
|
if (node.children != null) {
|
|
var walker = node.children;
|
|
var hook;
|
|
while (walker != null) {
|
|
hook = walker.next;
|
|
if (!this.preOrderInternalVisitable(walker, userData)) {
|
|
return false;
|
|
}
|
|
walker = hook;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
preOrderInternalVisitablePreflight(node, userData) {
|
|
var v = node.val;
|
|
if (v.visit(true, userData)) {
|
|
if (v.visit(false, userData)) {
|
|
if (node.children != null) {
|
|
var walker = node.children;
|
|
var hook;
|
|
while (walker != null) {
|
|
hook = walker.next;
|
|
if (!this.preOrderInternalVisitablePreflight(walker, userData)) {
|
|
return false;
|
|
}
|
|
walker = hook;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
get_size() {
|
|
var c = 1;
|
|
var node = this.children;
|
|
while (node != null) {
|
|
c += node.get_size();
|
|
node = node.next;
|
|
}
|
|
return c;
|
|
}
|
|
clone(byRef, copier) {
|
|
if (byRef == null) {
|
|
byRef = true;
|
|
}
|
|
var stack = [];
|
|
var copy = new polygonal_ds_TreeNode(copier != null ? copier(this.val) : this.val);
|
|
stack[0] = this;
|
|
stack[1] = copy;
|
|
var i = 2;
|
|
while (i > 0) {
|
|
var c = stack[--i];
|
|
var n = stack[--i];
|
|
c.mExtraInfo = c.mExtraInfo & 65535 | n.mExtraInfo >>> 16 << 16;
|
|
if (n.children != null) {
|
|
var nchild = n.children;
|
|
var x = nchild.val;
|
|
var x1 = byRef ? x : copier == null ? (js_Boot.__cast(x, polygonal_ds_Cloneable)).clone() : copier(x);
|
|
var cchild = c.children = new polygonal_ds_TreeNode(x1, c);
|
|
stack[i++] = nchild;
|
|
stack[i++] = cchild;
|
|
nchild = nchild.next;
|
|
while (nchild != null) {
|
|
var x2 = nchild.val;
|
|
x1 = byRef ? x2 : copier == null ? (js_Boot.__cast(x2, polygonal_ds_Cloneable)).clone() : copier(x2);
|
|
cchild.next = new polygonal_ds_TreeNode(x1, c);
|
|
cchild = cchild.next;
|
|
c.mTail = cchild;
|
|
stack[i++] = nchild;
|
|
stack[i++] = cchild;
|
|
nchild = nchild.next;
|
|
}
|
|
}
|
|
}
|
|
return copy;
|
|
}
|
|
}
|
|
polygonal_ds_TreeNode.__name__ = true;
|
|
polygonal_ds_TreeNode.__interfaces__ = [polygonal_ds_Collection];
|
|
Object.assign(polygonal_ds_TreeNode.prototype, {
|
|
__class__: polygonal_ds_TreeNode
|
|
});
|
|
class polygonal_ds_ChildTreeIterator {
|
|
constructor(x) {
|
|
this.mObject = x;
|
|
this.mWalker = this.mObject.children;
|
|
this.mHook = null;
|
|
}
|
|
hasNext() {
|
|
return this.mWalker != null;
|
|
}
|
|
next() {
|
|
var x = this.mWalker.val;
|
|
this.mHook = this.mWalker;
|
|
this.mWalker = this.mWalker.next;
|
|
return x;
|
|
}
|
|
}
|
|
polygonal_ds_ChildTreeIterator.__name__ = true;
|
|
polygonal_ds_ChildTreeIterator.__interfaces__ = [polygonal_ds_Itr];
|
|
Object.assign(polygonal_ds_ChildTreeIterator.prototype, {
|
|
__class__: polygonal_ds_ChildTreeIterator
|
|
});
|
|
class polygonal_ds_Visitable {}
|
|
polygonal_ds_Visitable.__name__ = true;
|
|
polygonal_ds_Visitable.__isInterface__ = true;
|
|
Object.assign(polygonal_ds_Visitable.prototype, {
|
|
__class__: polygonal_ds_Visitable
|
|
});
|
|
String.prototype.__class__ = String;
|
|
String.__name__ = true;
|
|
Array.__name__ = true;
|
|
var Int = {};
|
|
var Dynamic = {};
|
|
var Float = Number;
|
|
var Bool = Boolean;
|
|
var Class = {};
|
|
var Enum = {};
|
|
var __map_reserved = {};
|
|
Object.defineProperty(js__$Boot_HaxeError.prototype, "message", {
|
|
get: function () {
|
|
return String(this.val);
|
|
}
|
|
});
|
|
js_Boot.__toStr = ({}).toString;
|
|
MainBoCai.main();
|
|
})(serve, serve);
|
|
export default serve;
|