|
@@ -6,8 +6,6 @@
|
|
|
*/
|
|
*/
|
|
|
package net.ranides.assira.collection.lists;
|
|
package net.ranides.assira.collection.lists;
|
|
|
|
|
|
|
|
-import net.ranides.assira.collection.sets.FlatSet;
|
|
|
|
|
-
|
|
|
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
@@ -45,7 +43,7 @@ public class FlatList<T> extends AbstractSequentialList<T> implements Serializab
|
|
|
@SafeVarargs
|
|
@SafeVarargs
|
|
|
public FlatList(List<T>... values) {
|
|
public FlatList(List<T>... values) {
|
|
|
this();
|
|
this();
|
|
|
- joinAll(Arrays.asList(values));
|
|
|
|
|
|
|
+ content.addAll(Arrays.asList(values));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,30 +52,18 @@ public class FlatList<T> extends AbstractSequentialList<T> implements Serializab
|
|
|
*/
|
|
*/
|
|
|
public FlatList(Stream<List<T>> values) {
|
|
public FlatList(Stream<List<T>> values) {
|
|
|
this();
|
|
this();
|
|
|
- joinAll(values);
|
|
|
|
|
|
|
+ values.forEachOrdered(content::add);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates merged view of provided lists
|
|
* Creates merged view of provided lists
|
|
|
* @param values values
|
|
* @param values values
|
|
|
*/
|
|
*/
|
|
|
- public FlatList(List<List<T>> values) {
|
|
|
|
|
|
|
+ public FlatList(Collection<List<T>> values) {
|
|
|
this();
|
|
this();
|
|
|
- joinAll(values);
|
|
|
|
|
|
|
+ content.addAll(values);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Creates merged view of provided collections
|
|
|
|
|
- *
|
|
|
|
|
- * @param values values
|
|
|
|
|
- * @param <T> type
|
|
|
|
|
- * @return view
|
|
|
|
|
- */
|
|
|
|
|
- @SafeVarargs
|
|
|
|
|
- public static <T> FlatList<T> of(List<T>... values) {
|
|
|
|
|
- return new FlatList<T>(values);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Inserts list at the end of merged view.
|
|
* Inserts list at the end of merged view.
|
|
|
* Please note that it stores container, not actual elements from it.
|
|
* Please note that it stores container, not actual elements from it.
|
|
@@ -89,62 +75,6 @@ public class FlatList<T> extends AbstractSequentialList<T> implements Serializab
|
|
|
content.add(list);
|
|
content.add(list);
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Inserts list into at specified position merged view.
|
|
|
|
|
- * Please note that it stores container, not actual elements from it.
|
|
|
|
|
- *
|
|
|
|
|
- * Parameter "index" is related to merged lists, not elements.
|
|
|
|
|
- * That means: if you merged 4 lists of size 10, then you can join at positions: 0...3, not 0...40
|
|
|
|
|
- *
|
|
|
|
|
- * @param index index
|
|
|
|
|
- * @param list list
|
|
|
|
|
- * @return this
|
|
|
|
|
- */
|
|
|
|
|
- public FlatList<T> join(int index, List<T> list) {
|
|
|
|
|
- content.add(index, list);
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /***
|
|
|
|
|
- * Inserts specified list at the end of merged view.
|
|
|
|
|
- * Please note that it stores containers, not actual elements from them.
|
|
|
|
|
- *
|
|
|
|
|
- * @param list list
|
|
|
|
|
- * @return this
|
|
|
|
|
- */
|
|
|
|
|
- public final FlatList<T> joinAll(List<List<T>> list) {
|
|
|
|
|
- content.addAll(list);
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /***
|
|
|
|
|
- * Inserts specified lists at the end of merged view.
|
|
|
|
|
- * Please note that it stores containers, not actual elements from them.
|
|
|
|
|
- *
|
|
|
|
|
- * @param stream stream
|
|
|
|
|
- * @return this
|
|
|
|
|
- */
|
|
|
|
|
- public final FlatList<T> joinAll(Stream<List<T>> stream) {
|
|
|
|
|
- stream.forEachOrdered(content::add);
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Inserts specified lists at the end of merged view.
|
|
|
|
|
- * Please note that it stores containers, not actual elements from them.
|
|
|
|
|
- *
|
|
|
|
|
- * Parameter "index" is related to merged lists, not elements.
|
|
|
|
|
- * That means: if you merged 4 lists of size 10, then you can join at positions: 0...3, not 0...40
|
|
|
|
|
- *
|
|
|
|
|
- * @param index index
|
|
|
|
|
- * @param list list
|
|
|
|
|
- * @return this
|
|
|
|
|
- */
|
|
|
|
|
- public final FlatList<T> joinAll(int index, List<List<T>> list) {
|
|
|
|
|
- content.addAll(index, list);
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int size() {
|
|
public int size() {
|