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:
@@ -4,6 +4,12 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
#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.Comparator;
|
||||
@@ -214,6 +220,42 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||
#if TYPE_OBJECT
|
||||
/**
|
||||
* Creates a Collector for a RBTreeSet
|
||||
* @Type(T)
|
||||
* @return a collector
|
||||
*/
|
||||
public static <T> Collector<T, RB_TREE_SET<T>, RB_TREE_SET<T>> toSet() {
|
||||
return Collector.of(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects a Stream to a RBTreeSet
|
||||
* @Type(T)
|
||||
* @return a set with the contents of the Stream
|
||||
*/
|
||||
public static <T> RB_TREE_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
||||
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
||||
}
|
||||
|
||||
private RB_TREE_SET<T> merge(RB_TREE_SET<T> a) {
|
||||
addAll(a);
|
||||
return this;
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Collects a Stream to a RBTreeSet
|
||||
* @return a set with the contents of the Stream
|
||||
*/
|
||||
public static RB_TREE_SET toSet(JAVA_STREAM stream) {
|
||||
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::addAll);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||
|
||||
Reference in New Issue
Block a user