From ede40f06d05b9261eb454241ed20e74692cb5925 Mon Sep 17 00:00:00 2001 From: Speiger Date: Thu, 14 Apr 2022 05:37:41 +0200 Subject: [PATCH] Small fixes. -Fixed: Some imports. -Fixed: containsValue for OpenHashMap was not checking nullEntry properly --- .../templates/collections/AbstractCollection.template | 1 - .../templates/collections/Iterable.template | 1 - .../maps/impl/customHash/OpenCustomHashMap.template | 8 +++++++- .../templates/maps/impl/hash/OpenHashMap.template | 10 ++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template index 6443b86..d895a62 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template @@ -7,7 +7,6 @@ import java.util.AbstractCollection; import java.util.function.Consumer; #endif -import speiger.src.collections.PACKAGE.collections.COLLECTION; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.PACKAGE.utils.ITERATORS; 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 ddce726..cdae093 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template @@ -14,7 +14,6 @@ import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; 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 diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template index 426eb11..418e885 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template @@ -316,6 +316,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL #if !VALUE_OBJECT @Override public boolean containsValue(VALUE_TYPE value) { + if(containsNull && VALUE_EQUALS(values[nullIndex], value)) return true; for(int i = nullIndex;i >= 0;i--) if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && VALUE_EQUALS(values[i], value)) return true; return false; @@ -325,7 +326,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL @Override @ValuePrimitive public boolean containsValue(Object value) { - for(int i = nullIndex;i >= 0;i--) +#if VALUE_OBJECT + if(containsNull && VALUE_EQUALS(values[nullIndex], value)) return true; +#else + if(containsNull && ((value == null && values[nullIndex] == getDefaultReturnValue()) || EQUALS_VALUE_TYPE(values[nullIndex], value))) return true; +#endif + for(int i = nullIndex-1;i >= 0;i--) #if VALUE_OBJECT if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && EQUALS_VALUE_TYPE(values[i], value)) return true; #else diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template index 3429412..b207019 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template @@ -287,7 +287,8 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE #if !VALUE_OBJECT @Override public boolean containsValue(VALUE_TYPE value) { - for(int i = nullIndex;i >= 0;i--) + if(containsNull && VALUE_EQUALS(values[nullIndex], value)) return true; + for(int i = nullIndex-1;i >= 0;i--) if(KEY_EQUALS_NOT_NULL(keys[i]) && VALUE_EQUALS(values[i], value)) return true; return false; } @@ -296,7 +297,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE @Override @ValuePrimitive public boolean containsValue(Object value) { - for(int i = nullIndex;i >= 0;i--) +#if VALUE_OBJECT + if(containsNull && VALUE_EQUALS(values[nullIndex], value)) return true; +#else + if(containsNull && ((value == null && values[nullIndex] == getDefaultReturnValue()) || EQUALS_VALUE_TYPE(values[nullIndex], value))) return true; +#endif + for(int i = nullIndex-1;i >= 0;i--) #if VALUE_OBJECT if(KEY_EQUALS_NOT_NULL(keys[i]) && EQUALS_VALUE_TYPE(values[i], value)) return true; #else