@Test public void testPutAllAtRoot() { Prefix prefix = Prefix.parse("128.0.0.0/1"); PrefixTrieMultiMap<Integer> map = new PrefixTrieMultiMap<>(prefix); assertThat(entriesPostOrder(map), contains(immutableEntry(prefix, ImmutableSet.of()))); ImmutableSet<Integer> zeroValues = ImmutableSet.of(1, 2); assertTrue(map.putAll(Prefix.ZERO, zeroValues)); assertThat( entriesPostOrder(map), contains( immutableEntry(prefix, ImmutableSet.of()), immutableEntry(Prefix.ZERO, zeroValues))); }
public boolean putAll(Prefix p, Collection<T> elements) { if (_root == null || !_root._prefix.containsPrefix(p)) { _root = combine(new Node<T>(p, elements), _root); return true; } Node<T> node = _root.findOrCreateNode(p); if (node._elements.containsAll(elements)) { return false; } node._elements = ImmutableSet.<T>builder().addAll(node._elements).addAll(elements).build(); return true; }
PrefixTrieMultiMap implements Serializable { public boolean putAll(Prefix p, Collection<T> elements) { if (_root == null || !_root._prefix.containsPrefix(p)) { _root = combine(new Node<T>(p, elements), _root); return true; } Node<T> node = _root.findOrCreateNode(p); if (node._elements.containsAll(elements)) { return false; } node._elements = ImmutableSet.<T>builder().addAll(node._elements).addAll(elements).build(); return true; } }
PrefixTrieMultiMap implements Serializable { public boolean putAll(Prefix p, Collection<T> elements) { if (_root == null || !_root._prefix.containsPrefix(p)) { _root = combine(new Node<T>(p, elements), _root); return true; } Node<T> node = _root.findOrCreateNode(p); if (node._elements.containsAll(elements)) { return false; } node._elements = ImmutableSet.<T>builder().addAll(node._elements).addAll(elements).build(); return true; } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); }
PrefixTrieMultiMap implements Serializable { public boolean putAll(Prefix p, Collection<T> elements) { if (_root == null || !_root._prefix.containsPrefix(p)) { _root = combine(new Node<T>(p, elements), _root); return true; } Node<T> node = _root.findOrCreateNode(p); if (node._elements.containsAll(elements)) { return false; } node._elements = ImmutableSet.<T>builder().addAll(node._elements).addAll(elements).build(); 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 putAll(Prefix p, Collection<T> elements) { if (_root == null || !_root._prefix.containsPrefix(p)) { _root = combine(new Node<T>(p, elements), _root); return true; } Node<T> node = _root.findOrCreateNode(p); if (node._elements.containsAll(elements)) { return false; } node._elements = ImmutableSet.<T>builder().addAll(node._elements).addAll(elements).build(); 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();  }