(List<Pair<Double, Integer>> S)
| 321 | |
| 322 | //The probability match is used to store and sort by median distances. |
| 323 | private TreeNode makeVPTree(List<Pair<Double, Integer>> S) |
| 324 | { |
| 325 | if(S.isEmpty()) |
| 326 | return null; |
| 327 | else if(S.size() <= maxLeafSize) |
| 328 | { |
| 329 | VPLeaf leaf = new VPLeaf(S); |
| 330 | return leaf; |
| 331 | } |
| 332 | |
| 333 | int vpIndex = selectVantagePointIndex(S); |
| 334 | final VPNode node = new VPNode(S.get(vpIndex).getSecondItem()); |
| 335 | |
| 336 | //move VP to front, its self dist is zero and we dont want it used in computing bounds. |
| 337 | Collections.swap(S, 0, vpIndex); |
| 338 | int splitIndex = sortSplitSet(S.subList(1, S.size()), node)+1;//ofset by 1 b/c we sckipped the VP, which was moved to the front |
| 339 | |
| 340 | /* |
| 341 | * Re use the list and let it get altered. We must compute the right side first. |
| 342 | * If we altered the left side, the median would move left, and the right side |
| 343 | * would get thrown off or require aditonal book keeping. |
| 344 | */ |
| 345 | node.right = makeVPTree(S.subList(splitIndex+1, S.size())); |
| 346 | node.left = makeVPTree(S.subList(1, splitIndex+1)); |
| 347 | |
| 348 | return node; |
| 349 | } |
| 350 | |
| 351 | private TreeNode makeVPTree(final List<Pair<Double, Integer>> S, final ExecutorService threadpool, final ModifiableCountDownLatch mcdl) |
| 352 | { |
no test coverage detected