@Test public void testNetworkSetAdd() throws Exception { NetworkSet set = new NetworkSet(); addRange(set, "1.2.3.4", "1.3.5.6"); assertSize(set, 17); }
private void addRange(@Nonnull byte[] start, @Nonnull byte[] end, int delta) { START: { Address key = new Address(start); Count count = data.get(key); if (count == null) data.put(key, new Count(delta)); else if (count.add(delta)) data.remove(key); } END: { Address key = new Address(end); Count count = data.get(key); if (count == null) data.put(key, new Count(-delta)); else if (count.add(-delta)) data.remove(key); } }
NetworkSet { private void addRange(@Nonnull byte[] start, @Nonnull byte[] end, int delta) { START: { Address key = new Address(start); Count count = data.get(key); if (count == null) data.put(key, new Count(delta)); else if (count.add(delta)) data.remove(key); } END: { Address key = new Address(end); Count count = data.get(key); if (count == null) data.put(key, new Count(-delta)); else if (count.add(-delta)) data.remove(key); } } }
NetworkSet { private void addRange(@Nonnull byte[] start, @Nonnull byte[] end, int delta) { START: { Address key = new Address(start); Count count = data.get(key); if (count == null) data.put(key, new Count(delta)); else if (count.add(delta)) data.remove(key); } END: { Address key = new Address(end); Count count = data.get(key); if (count == null) data.put(key, new Count(-delta)); else if (count.add(-delta)) data.remove(key); } }  }
NetworkSet { private void addRange(@Nonnull byte[] start, @Nonnull byte[] end, int delta) { START: { Address key = new Address(start); Count count = data.get(key); if (count == null) data.put(key, new Count(delta)); else if (count.add(delta)) data.remove(key); } END: { Address key = new Address(end); Count count = data.get(key); if (count == null) data.put(key, new Count(-delta)); else if (count.add(-delta)) data.remove(key); } }  void addRange(@Nonnull InetAddress start, @Nonnull InetAddress end); void removeRange(@Nonnull InetAddress start, @Nonnull InetAddress end); void addRange(@Nonnull InetAddressRange range); void removeRange(@Nonnull InetAddressRange range); void addNetwork(@Nonnull NetworkAddress network); void removeNetwork(@Nonnull NetworkAddress network); void addAddress(@Nonnull InetAddress address); void removeAddress(@Nonnull InetAddress address); @Nonnull List<NetworkAddress> toNetworkList(); @Nonnull List<InetAddressRange> toAddressRangeList(); }
NetworkSet { private void addRange(@Nonnull byte[] start, @Nonnull byte[] end, int delta) { START: { Address key = new Address(start); Count count = data.get(key); if (count == null) data.put(key, new Count(delta)); else if (count.add(delta)) data.remove(key); } END: { Address key = new Address(end); Count count = data.get(key); if (count == null) data.put(key, new Count(-delta)); else if (count.add(-delta)) data.remove(key); } }  void addRange(@Nonnull InetAddress start, @Nonnull InetAddress end); void removeRange(@Nonnull InetAddress start, @Nonnull InetAddress end); void addRange(@Nonnull InetAddressRange range); void removeRange(@Nonnull InetAddressRange range); void addNetwork(@Nonnull NetworkAddress network); void removeNetwork(@Nonnull NetworkAddress network); void addAddress(@Nonnull InetAddress address); void removeAddress(@Nonnull InetAddress address); @Nonnull List<NetworkAddress> toNetworkList(); @Nonnull List<InetAddressRange> toAddressRangeList();  }