function VPTree(distance, items) {
  if (typeof distance !== 'function')
    throw new Error('mnemonist/VPTree.constructor: given `distance` must be a function.');

  if (!items)
    throw new Error('mnemonist/VPTree.constructor: you must provide items to the tree. A VPTree cannot be updated after its creation.');

  // Properties
  this.distance = distance;
  this.heap = new Heap(comparator);
  this.D = 0;

  var arrays = iterables.toArrayWithIndices(items);
  this.items = arrays[0];
  var indices = arrays[1];

  // Creating the binary tree
  this.size = indices.length;

  var result = createBinaryTree(distance, this.items, indices);

  this.nodes = result.nodes;
  this.lefts = result.lefts;
  this.rights = result.rights;
  this.mus = result.mus;
}
VPTree.

@constructor
@param {function} distance - Distance function to use.
@param {Iterable} items    - Items to store.