Skip to content

Commit

Permalink
feat: return if no parent for bottm
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelAHM committed Jan 14, 2025
1 parent 0102f05 commit b000aea
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ private List<IpEntry> searchBottomResources(final IpTree ipTree, final IpInterva
private void extractBottomMatches(final IpTree ipTree, final IpInterval searchIp,
final IpEntry mostSpecificResource,
final Set<IpEntry> mostSpecificFillingOverlaps) {

mostSpecificFillingOverlaps.add(mostSpecificResource);

final IpInterval mostSpecificInterval = IpInterval.parse(mostSpecificResource.getKey().toString());
final List<IpEntry> parentList = ipTree.findFirstLessSpecific(mostSpecificInterval);
final List<IpEntry> siblingsAndExact = findSiblingsAndExact(ipTree, mostSpecificInterval, parentList);

if (parentList.isEmpty()){
return;
}

final List<IpEntry> siblingsAndExact = findSiblingsAndExact(ipTree, parentList);

final IpInterval firstSibling = (IpInterval)siblingsAndExact.getFirst().getKey();
final IpInterval lastSibling = (IpInterval)siblingsAndExact.getLast().getKey();
Expand All @@ -117,10 +123,7 @@ private static boolean childrenCoverParentRange(final IpInterval firstResource,
lastResource.endAsInetAddress().equals(parent.endAsInetAddress());
}

private static List<IpEntry> findSiblingsAndExact(final IpTree ipTree, final IpInterval parentResource, final List<IpEntry> parent) {
if (parent.isEmpty()){
return ipTree.findExact(parentResource);
}
private static List<IpEntry> findSiblingsAndExact(final IpTree ipTree, final List<IpEntry> parent) {
return ipTree.findFirstMoreSpecific(IpInterval.parse(parent.getFirst().getKey().toString()));
}

Expand Down

0 comments on commit b000aea

Please sign in to comment.