ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [4/4] ignite git commit: IGNITE-2263: Optimized forAll() and forAny() methods.
Date Wed, 30 Dec 2015 11:23:10 GMT
IGNITE-2263: Optimized forAll() and forAny() methods.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6f7de6ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6f7de6ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6f7de6ac

Branch: refs/heads/ignite-2263
Commit: 6f7de6ac2c815b18ef561bba1366a93065f4a997
Parents: 9f02041
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Dec 30 14:24:03 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Dec 30 14:24:03 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/lang/GridFunc.java      | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6f7de6ac/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index bc7252f..4036686 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -62,7 +62,6 @@ import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteClosure;
 import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.lang.IgniteOutClosure;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.lang.IgniteReducer;
 import org.jetbrains.annotations.NotNull;
@@ -2714,6 +2713,7 @@ public class GridFunc {
      * @param p Predicate.
      * @return {@code True} if test is passed.
      */
+    // TODO: To be removed!
     public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super
T> p) {
         return p == null || p.apply(t);
     }
@@ -2932,14 +2932,14 @@ public class GridFunc {
      * @return Returns {@code true} if all given predicates evaluate to {@code true} for
      *      all elements. Returns {@code false} otherwise.
      */
-    public static <V> boolean forAll(Iterable<? extends V> c, @Nullable IgnitePredicate<?
super V>... p) {
+    public static <V> boolean forAll(Iterable<? extends V> c, IgnitePredicate<?
super V> p) {
         A.notNull(c, "c");
 
         if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;
-        else if (!isEmpty(p)) {
+        else {
             for (V v : c) {
                 if (!isAll(v, p))
                     return false;
@@ -2961,17 +2961,18 @@ public class GridFunc {
      *      entries. Returns {@code false} otherwise.
      */
     public static <K1, K extends K1, V1, V extends V1> boolean forAll(Map<K, V>
m,
-        @Nullable IgnitePredicate<? super Map.Entry<K, V>>... p) {
+        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))
+        else {
             for (Map.Entry<K, V> e : m.entrySet())
                 if (!isAll(e, p))
                     return false;
+        }
 
         return true;
     }
@@ -2988,14 +2989,10 @@ public class GridFunc {
      * @return Returns {@code true} if all given predicates evaluate to {@code true} for
      *      at least one element. Returns {@code false} otherwise.
      */
-    public static <V> boolean forAny(Iterable<? extends V> c, @Nullable IgnitePredicate<?
super V>... p) {
+    public static <V> boolean forAny(Iterable<? extends V> c, IgnitePredicate<?
super V> p) {
         A.notNull(c, "c");
 
-        if (!c.iterator().hasNext())
-            return false;
-        else if (isEmpty(p))
-            return true;
-        else if (isAlwaysFalse(p))
+        if (isAlwaysFalse(p))
             return false;
         else if (isAlwaysTrue(p))
             return true;


Mime
View raw message