From 17886dde62058a4855c61c07e3c68c3758e3ee89 Mon Sep 17 00:00:00 2001 From: Speiger Date: Fri, 28 May 2021 20:08:04 +0200 Subject: [PATCH] Fixes to SubSets. -Fixed: ToArray implementation works now. -Fixed: Creating SubSets from subsets is now no longer 1 element to small. --- .../templates/sets/ArraySet.template | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template index 830362e..7453099 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template @@ -19,10 +19,12 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; +import speiger.src.collections.objects.utils.ObjectArrays; #endif import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR; import speiger.src.collections.PACKAGE.utils.ARRAYS; + /** * A Type Specific ArraySet implementation. * That is based around the idea of {@link java.util.List#indexOf(Object)} for no duplication. @@ -355,6 +357,34 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im return size; } +#if !TYPE_OBJECT + @Override + public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) { + if(a == null || a.length < size()) return Arrays.copyOf(data, size()); + System.arraycopy(data, 0, a, 0, size()); + return a; + } + +#endif + @Override + @Deprecated + public Object[] toArray() { + Object[] obj = new Object[size()]; + for(int i = 0;i E[] toArray(E[] a) { + if(a == null) a = (E[])new Object[size()]; + else if(a.length < size()) a = (E[])ObjectArrays.newArray(a.getClass().getComponentType(), size()); + for(int i = 0;i E[] toArray(E[] a) { + if(a == null) a = (E[])new Object[size()]; + else if(a.length < size()) a = (E[])ObjectArrays.newArray(a.getClass().getComponentType(), size()); + for(int i = 0;i=0;i--)