createParentBoundables method

List createParentBoundables(
  1. List childBoundables,
  2. int newLevel
)

Sorts the childBoundables then divides them into groups of size M, where M is the node capacity.

Implementation

List createParentBoundables(List childBoundables, int newLevel) {
  Assert.isTrue(!childBoundables.isEmpty);
  List parentBoundables = [];
  parentBoundables.add(createNode(newLevel));
  List sortedChildBoundables = List.from(childBoundables);
  sortedChildBoundables.sort(getComparator());
  for (Iterator i = sortedChildBoundables.iterator; i.moveNext();) {
    Boundable childBoundable = i.current as Boundable;
    if (lastNode(parentBoundables).getChildBoundables().length ==
        getNodeCapacity()) {
      parentBoundables.add(createNode(newLevel));
    }
    lastNode(parentBoundables).addChildBoundable(childBoundable);
  }
  return parentBoundables;
}