From 54c9660145bf63094590e7c4c3266100f7ab7037 Mon Sep 17 00:00:00 2001 From: Speiger Date: Wed, 6 Oct 2021 20:23:40 +0200 Subject: [PATCH] New Tests & BugFixes -Added: Tests for the Copying of Collections. -Fixed: PriorityQueues didn't have hashCode/equals/toString implemented --- .../speiger/src/builder/GlobalVariables.java | 1 + .../builder/PrimitiveCollectionsBuilder.java | 1 + .../queues/AbstractPriorityQueue.template | 46 +++++++++++++++++++ .../templates/queues/ArrayFIFOQueue.template | 2 +- .../queues/ArrayPriorityQueue.template | 2 +- .../queues/HeapPriorityQueue.template | 2 +- .../sets/LinkedOpenCustomHashSet.template | 1 + .../templates/sets/LinkedOpenHashSet.template | 1 + .../ints/base/BaseInt2IntMapTest.java | 10 ++++ .../ints/base/BaseIntCollectionTest.java | 9 ++++ .../ints/base/BaseIntPriorityQueueTest.java | 9 ++++ .../src/collections/tests/CollectionTest.java | 3 +- .../src/collections/tests/MapTests.java | 3 +- .../collections/tests/PriorityQueueTest.java | 1 + 14 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/builder/resources/speiger/assets/collections/templates/queues/AbstractPriorityQueue.template diff --git a/src/builder/java/speiger/src/builder/GlobalVariables.java b/src/builder/java/speiger/src/builder/GlobalVariables.java index 80e14ae3..40e69571 100644 --- a/src/builder/java/speiger/src/builder/GlobalVariables.java +++ b/src/builder/java/speiger/src/builder/GlobalVariables.java @@ -184,6 +184,7 @@ public class GlobalVariables //Abstract Classes addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection"); + addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue"); addAbstractMapper("ABSTRACT_SET", "Abstract%sSet"); addAbstractMapper("ABSTRACT_LIST", "Abstract%sList"); addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2"); diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index 59c56762..20d60088 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -78,6 +78,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor nameRemapper.put("IArray", "I%sArray"); nameRemapper.put("AbstractMap", "Abstract%sMap"); nameRemapper.put("AbstractCollection", "Abstract%sCollection"); + nameRemapper.put("AbstractPriorityQueue", "Abstract%sPriorityQueue"); nameRemapper.put("AbstractSet", "Abstract%sSet"); nameRemapper.put("AbstractList", "Abstract%sList"); nameRemapper.put("EnumMap", "Enum2%sMap"); diff --git a/src/builder/resources/speiger/assets/collections/templates/queues/AbstractPriorityQueue.template b/src/builder/resources/speiger/assets/collections/templates/queues/AbstractPriorityQueue.template new file mode 100644 index 00000000..3667f7b2 --- /dev/null +++ b/src/builder/resources/speiger/assets/collections/templates/queues/AbstractPriorityQueue.template @@ -0,0 +1,46 @@ +package speiger.src.collections.PACKAGE.queues; + +#if TYPE_OBJECT +import java.util.Objects; +#endif +import java.util.StringJoiner; + +/** + * Helper class that implements all the essential methods for the PriorityQueues + * @Type(T) + */ +public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE +{ + @Override + public boolean equals(Object obj) { + if(obj instanceof PRIORITY_QUEUE) { + PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj; + if(queue.size() != size()) return false; + for(int i = 0,m=size();i