@Test public void testRemove() { PrefixTrieMultiMap<Integer> ptm1 = new PrefixTrieMultiMap<>(Prefix.ZERO); ptm1.put(Prefix.ZERO, 1); assertTrue("Nothing to remove", !ptm1.remove(Prefix.ZERO, 2)); assertTrue("Element removed", ptm1.remove(Prefix.ZERO, 1)); assertThat(ptm1.getAllElements(), empty()); }
public boolean remove(Prefix p, T e) { Node<T> node = exactMatchNode(p); if (node == null || !node._elements.contains(e)) { return false; } if (node._elements.size() == 1) { node._elements = ImmutableSet.of(); } else { node._elements = node._elements.stream() .filter(el -> !el.equals(e)) .collect(ImmutableSet.toImmutableSet()); } return true; }
PrefixTrieMultiMap implements Serializable { public boolean remove(Prefix p, T e) { Node<T> node = exactMatchNode(p); if (node == null || !node._elements.contains(e)) { return false; } if (node._elements.size() == 1) { node._elements = ImmutableSet.of(); } else { node._elements = node._elements.stream() .filter(el -> !el.equals(e)) .collect(ImmutableSet.toImmutableSet()); } return true; } }
PrefixTrieMultiMap implements Serializable { public boolean remove(Prefix p, T e) { Node<T> node = exactMatchNode(p); if (node == null || !node._elements.contains(e)) { return false; } if (node._elements.size() == 1) { node._elements = ImmutableSet.of(); } else { node._elements = node._elements.stream() .filter(el -> !el.equals(e)) .collect(ImmutableSet.toImmutableSet()); } return true; } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); }
PrefixTrieMultiMap implements Serializable { public boolean remove(Prefix p, T e) { Node<T> node = exactMatchNode(p); if (node == null || !node._elements.contains(e)) { return false; } if (node._elements.size() == 1) { node._elements = ImmutableSet.of(); } else { node._elements = node._elements.stream() .filter(el -> !el.equals(e)) .collect(ImmutableSet.toImmutableSet()); } return true; } 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 { public boolean remove(Prefix p, T e) { Node<T> node = exactMatchNode(p); if (node == null || !node._elements.contains(e)) { return false; } if (node._elements.size() == 1) { node._elements = ImmutableSet.of(); } else { node._elements = node._elements.stream() .filter(el -> !el.equals(e)) .collect(ImmutableSet.toImmutableSet()); } return true; } 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();  }