diff --git a/Changelog.md b/Changelog.md index c54906c..c09dca0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ - Added: OrderedMap/Set - Added: Deprecation to Functions that are specific to Ordered interfaces in the SortedMap/Set - Added: subFrom to Maps which is the counterpart of the addTo method +- Added: pourAsList and pourAsSet (booleans excluded for sets) to Iterable ### Version 0.5.2 - Fixed: Bugs with Queues starting with the wrong size diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template index 37f9a01..8e1f8eb 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template @@ -15,6 +15,12 @@ import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUME import speiger.src.collections.PACKAGE.functions.function.PREDICATE; import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; +import speiger.src.collections.PACKAGE.lists.LIST; +import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; +#if !TYPE_BOOLEAN +import speiger.src.collections.PACKAGE.sets.SET; +import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; +#endif import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.ITERABLES; import speiger.src.collections.PACKAGE.utils.ITERATORS; @@ -160,6 +166,24 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable return collection; } + /** + * A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList + * @return a new ArrayList of all elements + */ + default LIST KEY_GENERIC_TYPE pourAsList() { + return pour(new ARRAY_LISTBRACES()); + } + +#if !TYPE_BOOLEAN + /** + * A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet + * @return a new LinkedHashSet of all elements + */ + default SET KEY_GENERIC_TYPE pourAsSet() { + return pour(new LINKED_HASH_SETBRACES()); + } + +#endif /** * Helper function to reduce stream usage that allows to filter for any matches. * @param filter that should be applied