@Test public void testFold() { PrefixTrieMultiMap<Integer> map = new PrefixTrieMultiMap<>(Prefix.ZERO); Prefix l = Prefix.parse("0.0.0.0/8"); Prefix ll = Prefix.parse("0.0.0.0/16"); Prefix lr = Prefix.parse("0.128.0.0/16"); Prefix r = Prefix.parse("128.0.0.0/8"); Prefix rl = Prefix.parse("128.0.0.0/16"); Prefix rr = Prefix.parse("128.128.0.0/16"); map.put(l, 0); map.put(ll, 0); map.put(lr, 0); map.put(rr, 0); map.put(rl, 0); map.put(r, 0); List<Prefix> prefixes = map.fold( new FoldOperator<Integer, List<Prefix>>() { @Nonnull @Override public List<Prefix> fold( Prefix prefix, Set<Integer> elems, @Nullable List<Prefix> leftResult, @Nullable List<Prefix> rightResult) { List<Prefix> result = new ArrayList<>(); if (leftResult != null) { result.addAll(leftResult); } if (rightResult != null) { result.addAll(rightResult); } result.add(prefix); return result; } }); assertThat(prefixes, contains(ll, lr, l, rl, rr, r, Prefix.ZERO)); }
public <R> R fold(FoldOperator<T, R> operator) { if (_root == null) { return null; } return _root.fold(operator); }
PrefixTrieMultiMap implements Serializable { public <R> R fold(FoldOperator<T, R> operator) { if (_root == null) { return null; } return _root.fold(operator); } }
PrefixTrieMultiMap implements Serializable { public <R> R fold(FoldOperator<T, R> operator) { if (_root == null) { return null; } return _root.fold(operator); } PrefixTrieMultiMap(Prefix prefix);  PrefixTrieMultiMap(); }
PrefixTrieMultiMap implements Serializable { public <R> R fold(FoldOperator<T, R> operator) { if (_root == null) { return null; } return _root.fold(operator); } 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 <R> R fold(FoldOperator<T, R> operator) { if (_root == null) { return null; } return _root.fold(operator); } 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();  }