validate method

void validate()

Validate this tree. For testing.

Implementation

void validate() {
  _validateStructure(_root);
  _validateMetrics(_root);

  int freeCount = 0;
  DynamicTreeNode freeNode =
      _freeList != NULL_NODE ? _nodes[_freeList] : null;
  while (freeNode != null) {
    assert(0 <= freeNode.id && freeNode.id < _nodeCapacity);
    assert(freeNode == _nodes[freeNode.id]);
    freeNode = freeNode.parent;
    ++freeCount;
  }

  assert(getHeight() == computeHeight());

  assert(_nodeCount + freeCount == _nodeCapacity);
}