#184 polished a few rough edges, class diagram change, and removed warnings

This commit is contained in:
Narendra Pathai
2015-09-10 13:12:36 +05:30
parent 0148cd7d2a
commit efa7e01223
5 changed files with 108 additions and 128 deletions

View File

@ -25,27 +25,12 @@ public class App {
public static void main(String[] args) {
List<Integer> integerList = new ArrayList<Integer>() {
{
add(1);
add(-61);
add(14);
add(-22);
add(18);
add(-87);
add(6);
add(64);
add(-82);
add(26);
add(-98);
add(97);
add(45);
add(23);
add(2);
add(-68);
add(45);
}
};
List<Integer> integerList = new ArrayList<>();
integerList.addAll(Arrays.asList(
1, -61, 14, -22, 18, -87, 6, 64, -82, 26, -98, 97,
45, 23, 2, -68, 45
));
prettyPrint("The initial list contains: ", integerList);
List<Integer> firstFiveNegatives =
@ -105,10 +90,6 @@ public class App {
prettyPrint(", ", prefix, ".", iterable);
}
private static <TYPE> void prettyPrint(String prefix, String suffix, Iterable<TYPE> iterable) {
prettyPrint(", ", prefix, suffix, iterable);
}
private static <TYPE> void prettyPrint(String delimiter, String prefix, String suffix,
Iterable<TYPE> iterable) {
StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");

View File

@ -1,15 +1,14 @@
package com.iluwatar.fluentinterface.fluentiterable.lazy;
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
/**
* This is a lazy implementation of the FluentIterable interface. It evaluates all chained
* operations when a terminating operation is applied.

View File

@ -124,7 +124,7 @@ public class SimpleFluentIterable<TYPE> implements FluentIterable<TYPE> {
*/
@Override
public final <NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function) {
List<NEW_TYPE> temporaryList = new ArrayList();
List<NEW_TYPE> temporaryList = new ArrayList<>();
Iterator<TYPE> iterator = iterator();
while (iterator.hasNext()) {
temporaryList.add(function.apply(iterator.next()));