/** {@inheritDoc} */ @Override public boolean apply(T t) { return GridFunc.isAll(t, preds); }
/** {@inheritDoc} */ @Override public boolean apply(T t) { return !GridFunc.isAll(t, preds); }
/** {@inheritDoc} */ @Override public boolean containsKey(Object key) { return GridFunc.isAll((K)key, preds) && map.containsKey(key); } }
/** {@inheritDoc} */ @Override public boolean add(T e) { // Pass through (will fail for readonly). return GridFunc.isAll(e, preds) && col.add(e); }
/** {@inheritDoc} */ @Override public boolean containsKey(Object key) { return GridFunc.isAll((K)key, preds) && map.containsKey(key); } }
/** {@inheritDoc} */ @Override public boolean containsKey(Object key) { return GridFunc.isAll((K)key, preds) && set.contains(key); } }
/** {@inheritDoc} */ @Override public boolean apply(Map.Entry<K, V> e) { return GridFunc.isAll(e.getKey(), preds); }
/** {@inheritDoc} */ @Override public boolean containsKey(Object key) { return GridFunc.isAll((K)key, preds) && map.containsKey(key); }
/** {@inheritDoc} */ @Nullable @Override public V get(Object key) { return GridFunc.isAll((K)key, preds) ? map.get(key) : null; }
/** {@inheritDoc} */ @Nullable @Override public V1 get(Object key) { if (GridFunc.isAll((K)key, preds)) { V v = map.get(key); if (v != null) return clos.apply(v); } return null; }
/** {@inheritDoc} */ @Nullable @Override public V1 get(Object key) { if (GridFunc.isAll((K)key, preds)) { V v = map.get(key); if (v != null) return clos.apply((K)key, v); } return null; }
/** {@inheritDoc} */ @Nullable @Override public V put(K key, V val) { V oldVal = get(key); if (GridFunc.isAll(key, preds)) map.put(key, val); return oldVal; }
/** * Gets size of the given iterator with provided optional predicates. Iterator * will be traversed to get the count. * * @param it Iterator to size. * @param p Optional predicates that filters out elements from count. * @param <T> Type of the iterator. * @return Number of elements in the iterator for which all given predicates * evaluates to {@code true}. If no predicates is provided - all elements are counted. */ public static <T> int size(@Nullable Iterator<? extends T> it, @Nullable IgnitePredicate<? super T>... p) { if (it == null) return 0; int n = 0; if (!isAlwaysFalse(p)) { while (it.hasNext()) { if (isAll(it.next(), p)) n++; } } return n; }
/** * Adds (copies) to given collection using provided predicates. Element is copied if all * predicates evaluate to {@code true}. * * @param to Collection to copy to. * @param from Collection to copy from. * @param p Optional set of predicates to use for filtration. * @param <T> Type of the free variable for the predicate and type of the collection elements. * @return Collection to copy to. */ @Deprecated public static <T> Collection<T> copy(Collection<T> to, Iterable<? extends T> from, @Nullable IgnitePredicate<? super T>... p) { A.notNull(to, "to", from, "from"); if (!isAlwaysFalse(p)) { for (T t : from) { if (isAll(t, p)) to.add(t); } } return to; }
/** * Calls given {@code side-effect only} closure over the each element of the provided * collection. * * @param c Collection to call closure over. * @param f Side-effect only closure to call over the collection. * @param p Optional set of predicates. Only if collection element evaluates * to {@code true} for given predicates the closure will be applied to it. * If no predicates provided - closure will be applied to all collection * elements. * @param <X> Type of the free variable for the closure and type of the * collection elements. */ @Deprecated public static <X> void forEach(Iterable<? extends X> c, IgniteInClosure<? super X> f, @Nullable IgnitePredicate<? super X>... p) { A.notNull(c, "c", f, "f"); for (X x : c) if (isAll(x, p)) f.apply(x); }
else if (!isAlwaysFalse(p)) for (Iterator<Map.Entry<K, V>> iter = m.entrySet().iterator(); iter.hasNext();) if (isAll(iter.next(), p)) iter.remove();
/** * Applies given predicates to all entries in given input map and returns {@code true} * if all of them evaluates to {@code true} for all entries. Returns {@code false} otherwise. * * @param m Input map. * @param p Optional set of checking predicate. * @param <K> Type of the map keys. * @param <V> Type of the map values. * @return Returns {@code true} if all given predicate evaluates to {@code true} for all * entries. Returns {@code false} otherwise. */ @Deprecated public static <K1, K extends K1, V1, V extends V1> boolean forAll(Map<K, V> m, @Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) { A.notNull(m, "m"); if (isAlwaysFalse(p)) return false; else if (isAlwaysTrue(p)) return true; else if (!isEmpty(p)) for (Map.Entry<K, V> e : m.entrySet()) if (!isAll(e, p)) return false; return true; }
/** * Applies all given predicates to all elements in given input collection and returns * {@code true} if all of them evaluate to {@code true} for all elements. Returns * {@code false} otherwise. * * @param c Input collection. * @param p Optional set of checking predicates. If none provided - {@code true} is returned. * @param <V> Type of the collection element. * @return Returns {@code true} if all given predicates evaluate to {@code true} for * all elements. Returns {@code false} otherwise. */ @Deprecated public static <V> boolean forAll(Iterable<? extends V> c, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c"); if (isAlwaysFalse(p)) return false; else if (isAlwaysTrue(p)) return true; else if (!isEmpty(p)) { for (V v : c) { if (!isAll(v, p)) return false; } } return true; }
/** * Checks for existence of the element in input collection for which all provided predicates * evaluate to {@code true}. * * @param c Input collection. * @param p Optional set of checking predicates. * @param <V> Type of the collection elements. * @return {@code true} if input collection contains element for which all the provided * predicates evaluates to {@code true} - otherwise returns {@code false}. */ public static <V> boolean exist(Iterable<? extends V> c, @Nullable IgnitePredicate<? super V>... p) { A.notNull(c, "c"); if (isAlwaysFalse(p)) return false; else if (isAlwaysTrue(p)) return true; else if (isEmpty(p)) return true; else for (V v : c) if (isAll(v, p)) return true; return false; }