@Test public void testLongestPrefixMatch() { PrefixTrieMultiMap<Integer> ptm1 = new PrefixTrieMultiMap<>(Prefix.ZERO); Prefix p1 = Prefix.parse("1.1.1.0/24"); Prefix p2 = Prefix.parse("1.1.1.128/25"); Prefix p3 = Prefix.parse("1.1.1.129/32"); ptm1.put(p1, 1); ptm1.put(p2, 2); ptm1.put(p3, 3); assertThat(ptm1.longestPrefixMatch(Ip.parse("1.1.1.1")), equalTo(ImmutableSet.of(1))); assertThat(ptm1.longestPrefixMatch(Ip.parse("1.1.1.128")), equalTo(ImmutableSet.of(2))); assertThat(ptm1.longestPrefixMatch(Ip.parse("1.1.1.128"), 1), empty()); assertThat(ptm1.longestPrefixMatch(Ip.parse("1.1.1.129")), equalTo(ImmutableSet.of(3))); assertThat(ptm1.longestPrefixMatch(Ip.parse("1.1.1.130")), equalTo(ImmutableSet.of(2))); }
@Nonnull public Set<T> longestPrefixMatch(Ip address) { return longestPrefixMatch(address, Prefix.MAX_PREFIX_LENGTH); }
PrefixTrieMultiMap implements Serializable { @Nonnull public Set<T> longestPrefixMatch(Ip address) { return longestPrefixMatch(address, Prefix.MAX_PREFIX_LENGTH); } }
PrefixTrieMultiMap implements Serializable { @Nonnull public Set<T> longestPrefixMatch(Ip address) { return longestPrefixMatch(address, Prefix.MAX_PREFIX_LENGTH); } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); }
PrefixTrieMultiMap implements Serializable { @Nonnull public Set<T> longestPrefixMatch(Ip address) { return longestPrefixMatch(address, Prefix.MAX_PREFIX_LENGTH); } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); void traverseEntries(BiConsumer<Prefix, Set<T>> consumer); R fold(FoldOperator<T, R> operator); @Override boolean equals(Object o); @Nonnull Set<T> get(Prefix p); @Nonnull Set<T> getAllElements(); @Override int hashCode(); @Nonnull Set<T> longestPrefixMatch(Ip address); @Nonnull Set<T> longestPrefixMatch(Ip address, int maxPrefixLength); boolean put(Prefix p, T e); boolean putAll(Prefix p, Collection<T> elements); boolean remove(Prefix p, T e); boolean replaceAll(Prefix p, T e); void clear(); }
PrefixTrieMultiMap implements Serializable { @Nonnull public Set<T> longestPrefixMatch(Ip address) { return longestPrefixMatch(address, Prefix.MAX_PREFIX_LENGTH); } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); void traverseEntries(BiConsumer<Prefix, Set<T>> consumer); R fold(FoldOperator<T, R> operator); @Override boolean equals(Object o); @Nonnull Set<T> get(Prefix p); @Nonnull Set<T> getAllElements(); @Override int hashCode(); @Nonnull Set<T> longestPrefixMatch(Ip address); @Nonnull Set<T> longestPrefixMatch(Ip address, int maxPrefixLength); boolean put(Prefix p, T e); boolean putAll(Prefix p, Collection<T> elements); boolean remove(Prefix p, T e); boolean replaceAll(Prefix p, T e); void clear();  }