@Test @Disabled("too many permuations to go over") public void testLookup() throws IOException { IPLookup ipArt = new IPLookup(() -> new AdaptiveRadixTree<>(InetAddressBinaryComparable.INSTANCE)); IPLookup ipRbt = new IPLookup(() -> new TreeMap<>(InetAddressComparator.INSTANCE)); for (int i = 0; i < 256; i++) { String iaddress = i + "."; for (int j = 0; j < 256; j++) { String jaddress = iaddress + j + "."; for (int k = 0; k < 256; k++) { String kaddress = jaddress + k + "."; for (int l = 0; l < 256; l++) { InetAddress inetAddress = InetAddress.getByName(kaddress + l); assertEquals(ipArt.lookup(inetAddress), ipRbt.lookup(inetAddress)); } } } } }
Optional<String> lookup(InetAddress lookup) { Map.Entry<InetAddress, Record> entry = m.floorEntry(lookup); if (entry != null) { InetAddress end = entry.getValue().getEnd(); if (InetAddressComparator.INSTANCE.compare(end, lookup) >= 0) { return Optional.of(entry.getValue().getCountry()); } } return Optional.empty(); }
IPLookup { Optional<String> lookup(InetAddress lookup) { Map.Entry<InetAddress, Record> entry = m.floorEntry(lookup); if (entry != null) { InetAddress end = entry.getValue().getEnd(); if (InetAddressComparator.INSTANCE.compare(end, lookup) >= 0) { return Optional.of(entry.getValue().getCountry()); } } return Optional.empty(); } }
IPLookup { Optional<String> lookup(InetAddress lookup) { Map.Entry<InetAddress, Record> entry = m.floorEntry(lookup); if (entry != null) { InetAddress end = entry.getValue().getEnd(); if (InetAddressComparator.INSTANCE.compare(end, lookup) >= 0) { return Optional.of(entry.getValue().getCountry()); } } return Optional.empty(); } IPLookup(Supplier<NavigableMap<InetAddress, Record>> s); }
IPLookup { Optional<String> lookup(InetAddress lookup) { Map.Entry<InetAddress, Record> entry = m.floorEntry(lookup); if (entry != null) { InetAddress end = entry.getValue().getEnd(); if (InetAddressComparator.INSTANCE.compare(end, lookup) >= 0) { return Optional.of(entry.getValue().getCountry()); } } return Optional.empty(); } IPLookup(Supplier<NavigableMap<InetAddress, Record>> s);  }
IPLookup { Optional<String> lookup(InetAddress lookup) { Map.Entry<InetAddress, Record> entry = m.floorEntry(lookup); if (entry != null) { InetAddress end = entry.getValue().getEnd(); if (InetAddressComparator.INSTANCE.compare(end, lookup) >= 0) { return Optional.of(entry.getValue().getCountry()); } } return Optional.empty(); } IPLookup(Supplier<NavigableMap<InetAddress, Record>> s);   }