{"dependencies":[{"name":"C:\\Users\\alexbol\\WebstormProjects\\flatten-js\\package.json","includedInParent":true,"mtime":1520238055570},{"name":"C:\\Users\\alexbol\\WebstormProjects\\flatten-js\\node_modules\\flatten-interval-tree\\package.json","includedInParent":true,"mtime":1520238156082},{"name":"../classes/interval","loc":{"line":8,"column":23}},{"name":"../utils/constants","loc":{"line":9,"column":55}}],"generated":{"js":"/**\r\n * Created by Alex Bol on 4/1/2017.\r\n */\r\n\r\n'use strict';\r\n\r\n// let defaultTraits = require('../utils/numeric_traits');\r\nlet Interval = require('../classes/interval');\r\nlet {RB_TREE_COLOR_RED, RB_TREE_COLOR_BLACK} = require('../utils/constants');\r\n\r\nlet Node = class Node {\r\n    constructor(key = undefined, value = undefined,\r\n                left = null, right = null, parent = null, color = RB_TREE_COLOR_BLACK) {\r\n        this.left = left;                     // reference to left child node\r\n        this.right = right;                   // reference to right child node\r\n        this.parent = parent;                 // reference to parent node\r\n        this.color = color;\r\n\r\n        this.item = {key: key, value: value};   // key is supposed to be       instance of Interval\r\n\r\n        /* If not, this should by an array of two numbers */\r\n        if (key && key instanceof Array && key.length == 2) {\r\n            if (!Number.isNaN(key[0]) && !Number.isNaN(key[1])) {\r\n                this.item.key = new Interval(Math.min(key[0], key[1]), Math.max(key[0], key[1]));\r\n            }\r\n        }\r\n        this.max = this.item.key ? this.item.key.max : undefined;\r\n    }\r\n\r\n    isNil() {\r\n        return (this.item.key === undefined && this.item.value === undefined &&\r\n            this.left === null && this.right === null && this.color === RB_TREE_COLOR_BLACK);\r\n    }\r\n\r\n    less_than(other_node) {\r\n        return this.item.key.less_than(other_node.item.key);\r\n    }\r\n\r\n    equal_to(other_node) {\r\n        let value_equal = true;\r\n        if (this.item.value && other_node.item.value) {\r\n            value_equal = this.item.value.equal_to ? this.item.value.equal_to(other_node.item.value) :\r\n                this.item.value == other_node.item.value;\r\n        }\r\n        return this.item.key.equal_to(other_node.item.key) && value_equal;\r\n    }\r\n\r\n    intersect(other_node) {\r\n        return this.item.key.intersect(other_node.item.key);\r\n    }\r\n\r\n    copy_data(other_node) {\r\n        this.item.key = other_node.item.key.clone();\r\n        this.item.value = other_node.item.value;\r\n    }\r\n\r\n    update_max() {\r\n        // use key (Interval) max property instead of key.high\r\n        this.max = this.item.key ? this.item.key.max : undefined;\r\n        if (this.right && this.right.max) {\r\n            let maximal_val = this.item.key.maximal_val;\r\n            this.max = maximal_val(this.max, this.right.max);\r\n        }\r\n        if (this.left && this.left.max) {\r\n            let maximal_val = this.item.key.maximal_val;\r\n            this.max = maximal_val(this.max, this.left.max);\r\n        }\r\n    }\r\n\r\n    // Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low\r\n    not_intersect_left_subtree(search_node) {\r\n        let val_less_than = this.item.key.val_less_than;\r\n        let high = this.left.max.high ? this.left.max.high : this.left.max;\r\n        return val_less_than(high, search_node.item.key.low);\r\n    }\r\n\r\n    // Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low\r\n    not_intersect_right_subtree(search_node) {\r\n        let val_less_than = this.item.key.val_less_than;\r\n        let low = this.right.max.low ? this.right.max.low : this.right.item.key.low;\r\n        return val_less_than(search_node.item.key.high, low);\r\n    }\r\n};\r\n\r\nmodule.exports = Node;\r\n\r\n"},"hash":"8dc051704600b52626b15dc90e71e3ac","cacheData":{"env":{}}}