Fixes and new updates.
- Added: Collectors to lists/queues/sets - Fixed: Bugs in linked hash sets. - Fixed: Bugs in unit tests.
This commit is contained in:
+42
@@ -7,6 +7,12 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
#if JDK_TYPE
|
||||
import java.util.OPTIONAL;
|
||||
#if !TYPE_OBJECT
|
||||
import java.util.stream.JAVA_STREAM;
|
||||
#else
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.Collector;
|
||||
#endif
|
||||
#endif
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
@@ -211,6 +217,42 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
#endif
|
||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Creates a Collector for a LinkedHashSet
|
||||
* @Type(T)
|
||||
* @return a collector
|
||||
*/
|
||||
public static <T> Collector<T, LINKED_HASH_SET<T>, LINKED_HASH_SET<T>> toLinkedSet() {
|
||||
return Collector.of(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects a Stream to a LinkedHashSet
|
||||
* @Type(T)
|
||||
* @return a set with the contents of the Stream
|
||||
*/
|
||||
public static <T> LINKED_HASH_SET KEY_GENERIC_TYPE toLinkedSet(Stream<T> stream) {
|
||||
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
||||
}
|
||||
|
||||
private LINKED_HASH_SET<T> merge(LINKED_HASH_SET<T> a) {
|
||||
addAll(a);
|
||||
return this;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Collects a Stream to a LinkedHashSet
|
||||
* @return a set with the contents of the Stream
|
||||
*/
|
||||
public static LINKED_HASH_SET toLinkedSet(JAVA_STREAM stream) {
|
||||
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::addAll);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@Override
|
||||
public void addFirst(KEY_TYPE o) {
|
||||
|
||||
Reference in New Issue
Block a user