| OLD | NEW |
| 1 /******************************************************************************* | 1 /******************************************************************************* |
| 2 * Copyright (c) 2015, Daniel Murphy, Google | 2 * Copyright (c) 2015, Daniel Murphy, Google |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without modificati
on, | 5 * Redistribution and use in source and binary forms, with or without modificati
on, |
| 6 * are permitted provided that the following conditions are met: | 6 * are permitted provided that the following conditions are met: |
| 7 * * Redistributions of source code must retain the above copyright notice, | 7 * * Redistributions of source code must retain the above copyright notice, |
| 8 * this list of conditions and the following disclaimer. | 8 * this list of conditions and the following disclaimer. |
| 9 * * Redistributions in binary form must reproduce the above copyright notice, | 9 * * Redistributions in binary form must reproduce the above copyright notice, |
| 10 * this list of conditions and the following disclaimer in the documentation | 10 * this list of conditions and the following disclaimer in the documentation |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 assert(_nodeCount == _nodeCapacity); | 449 assert(_nodeCount == _nodeCapacity); |
| 450 | 450 |
| 451 List<DynamicTreeNode> old = _nodes; | 451 List<DynamicTreeNode> old = _nodes; |
| 452 _nodeCapacity *= 2; | 452 _nodeCapacity *= 2; |
| 453 _nodes = new List<DynamicTreeNode>(_nodeCapacity); | 453 _nodes = new List<DynamicTreeNode>(_nodeCapacity); |
| 454 BufferUtils.arraycopy(old, 0, _nodes, 0, old.length); | 454 BufferUtils.arraycopy(old, 0, _nodes, 0, old.length); |
| 455 | 455 |
| 456 // Build a linked list for the free list. | 456 // Build a linked list for the free list. |
| 457 for (int i = _nodeCapacity - 1; i >= _nodeCount; i--) { | 457 for (int i = _nodeCapacity - 1; i >= _nodeCount; i--) { |
| 458 _nodes[i] = new DynamicTreeNode(i); | 458 _nodes[i] = new DynamicTreeNode(i); |
| 459 _nodes[i].parent = | 459 _nodes[i].parent = (i == _nodeCapacity - 1) ? null : _nodes[i + 1]; |
| 460 (i == _nodeCapacity - 1) ? null : _nodes[i + 1]; | |
| 461 _nodes[i].height = -1; | 460 _nodes[i].height = -1; |
| 462 } | 461 } |
| 463 _freeList = _nodeCount; | 462 _freeList = _nodeCount; |
| 464 } | 463 } |
| 465 int nodeId = _freeList; | 464 int nodeId = _freeList; |
| 466 final DynamicTreeNode treeNode = _nodes[nodeId]; | 465 final DynamicTreeNode treeNode = _nodes[nodeId]; |
| 467 _freeList = treeNode.parent != null ? treeNode.parent.id : NULL_NODE; | 466 _freeList = treeNode.parent != null ? treeNode.parent.id : NULL_NODE; |
| 468 | 467 |
| 469 treeNode.parent = null; | 468 treeNode.parent = null; |
| 470 treeNode.child1 = null; | 469 treeNode.child1 = null; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 _textVec.x, _textVec.y, "$node.id-${(spot + 1)}/$height", _color); | 861 _textVec.x, _textVec.y, "$node.id-${(spot + 1)}/$height", _color); |
| 863 | 862 |
| 864 if (node.child1 != null) { | 863 if (node.child1 != null) { |
| 865 drawTreeX(argDraw, node.child1, spot + 1, height); | 864 drawTreeX(argDraw, node.child1, spot + 1, height); |
| 866 } | 865 } |
| 867 if (node.child2 != null) { | 866 if (node.child2 != null) { |
| 868 drawTreeX(argDraw, node.child2, spot + 1, height); | 867 drawTreeX(argDraw, node.child2, spot + 1, height); |
| 869 } | 868 } |
| 870 } | 869 } |
| 871 } | 870 } |
| OLD | NEW |