Commits

Stepan Koltsov committed 946696b

filter, partition and friends now take Function<?, Boolean> in addition to Function1B<?>

Comments (0)

Files changed (5)

src/main/java/ru/yandex/bolts/collection/CollectionF.java

      */
     CollectionF<E> filter(Function1B<? super E> p);
 
+    CollectionF<E> filter(Function<? super E, Boolean> p);
+
     CollectionF<E> filterW(@FunctionParameter boolean p);
 
     CollectionF<E> filterNotNull();
     /** Pair of collection, first contains elements matching p, second contains element matching !p */
     Tuple2<? extends IterableF<E>, ? extends IterableF<E>> partition(Function1B<? super E> p);
 
+    Tuple2<? extends IterableF<E>, ? extends IterableF<E>> partition(Function<? super E, Boolean> p);
+
     Tuple2<? extends IterableF<E>, ? extends IterableF<E>> partitionW(@FunctionParameter boolean p);
 
     /** Map */

src/main/java/ru/yandex/bolts/collection/ListF.java

 
     IteratorF<E> reverseIterator();
 
+    @Override
     ListF<E> filter(Function1B<? super E> p);
 
     @Override
+    ListF<E> filter(Function<? super E, Boolean> p);
+
+    @Override
     ListF<E> filterW(@FunctionParameter boolean p);
 
     @Override
      * Return pair of lists, first list contains elements matching <code>p</code>
      * and second lists contains elements matching <code>!p</code>.
      */
+    @Override
     Tuple2<ListF<E>, ListF<E>> partition(Function1B<? super E> p);
 
     @Override
+    Tuple2<ListF<E>, ListF<E>> partition(Function<? super E, Boolean> p);
+
+    @Override
     Tuple2<ListF<E>, ListF<E>> partitionW(@FunctionParameter boolean p);
 
     /** Sub list from index to index */
     /** Longest prefix of elements that satisfy p */
     ListF<E> takeWhile(Function1B<? super E> f);
 
+    ListF<E> takeWhile(Function<? super E, Boolean> f);
+
     ListF<E> takeWhileW(@FunctionParameter boolean p);
 
     /** Elements after {@link #takeWhile(Function1B)} */
     ListF<E> dropWhile(Function1B<? super E> f);
 
+    ListF<E> dropWhile(Function<? super E, Boolean> f);
+
     ListF<E> dropWhileW(@FunctionParameter boolean p);
 
     /** Pair of sublists returned by {@link #takeWhile(Function1B)} and {@link #dropWhile(Function1B)} */

src/main/java/ru/yandex/bolts/collection/SetF.java

     IteratorF<E> iterator();
 
     /** Filter */
+    @Override
     SetF<E> filter(Function1B<? super E> p);
 
+    @Override
     SetF<E> filterW(@FunctionParameter boolean p);
 
+    @Override
     SetF<E> filterNotNull();
 
     /**

src/main/java/ru/yandex/bolts/collection/impl/AbstractCollectionF.java

     }
 
     @Override
+    public CollectionF<E> filter(Function<? super E, Boolean> p) {
+        return filter(Function1B.wrap(p));
+    }
+
+    @Override
     public CollectionF<E> filterW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }
     }
 
     @Override
+    public Tuple2<? extends IterableF<E>, ? extends IterableF<E>> partition(Function<? super E, Boolean> p) {
+        return partition(Function1B.wrap(p));
+    }
+
+    @Override
     public Tuple2<? extends IterableF<E>, ? extends IterableF<E>> partitionW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }

src/main/java/ru/yandex/bolts/collection/impl/AbstractListF.java

         return iterator.toList();
     }
 
+    @Override
     public ListF<E> filter(Function1B<? super E> p) {
         return (ListF<E>) super.filter(p);
     }
 
     @Override
+    public ListF<E> filter(Function<? super E, Boolean> p) {
+        return (ListF<E>) super.filter(p);
+    }
+
+    @Override
     public ListF<E> filterW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }
         return (Tuple2<ListF<E>, ListF<E>>) super.filter2(p);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Tuple2<ListF<E>, ListF<E>> partition(Function1B<? super E> p) {
         return (Tuple2<ListF<E>, ListF<E>>) super.partition(p);
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
+    public Tuple2<ListF<E>, ListF<E>> partition(Function<? super E, Boolean> p) {
+        return (Tuple2<ListF<E>, ListF<E>>) super.partition(p);
+    }
+
     @Override
     public Tuple2<ListF<E>, ListF<E>> partitionW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }
 
     @Override
+    public ListF<E> dropWhile(Function<? super E, Boolean> f) {
+        return dropWhile(Function1B.wrap(f));
+    }
+
+    @Override
     public ListF<E> dropWhileW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }
     }
 
     @Override
+    public ListF<E> takeWhile(Function<? super E, Boolean> f) {
+        return takeWhile(Function1B.wrap(f));
+    }
+
+    @Override
     public ListF<E> takeWhileW(boolean p) {
         throw new RuntimeException("weaving must be enabled");
     }