From b99abaafec164169a729cd96dee6c72197afc9e8 Mon Sep 17 00:00:00 2001 From: Speiger Date: Sun, 27 Jun 2021 21:31:42 +0200 Subject: [PATCH] Fixed last second bugs. --- Changelog.md | 1 + README.md | 3 ++- .../templates/maps/impl/tree/AVLTreeMap.template | 4 ++++ .../templates/maps/interfaces/Map.template | 14 +++++++------- .../collections/templates/sets/AVLTreeSet.template | 1 + .../ints/base/BaseInt2IntSortedMapTest.java | 12 ++---------- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Changelog.md b/Changelog.md index c213b63d..448db3ee 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,7 @@ - Added: ImmutableOpenHashMap that is not editable (is linked by default for fast iteration) - Added: Maps can now be created through the interface. - Fixed: Lists.addElements(T...elements) was adding elements at the beginning of a list instead of the end. +- Fixed: Bugs with the AVLTreeSet. And marked bugs with AVLTreeX that are still present. ### Version 0.3.1 - Fixed: containsKey & containsValue in HashMaps were deprecated for Object Variants. diff --git a/README.md b/README.md index fa6acf4a..a911b45b 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,5 @@ do not combine the commands because they can not be executed at the same time. ## Current Down Sides (Random order) - Testing for Sub Maps/Sets/Lists are only in a very basic way tested -- Documentation is only present at the lowest level for most cases and needs a typo fixing. \ No newline at end of file +- Documentation is only present at the lowest level for most cases and needs a typo fixing. +- AVLTreeSet/Map Polling (pollFirst/LastKey) is not working properly. It does not crash just the order is not maintained for whatever reason. Will be fixed very soon. \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template index 75a57327..d6d13071 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template @@ -790,6 +790,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ protected int compare(KEY_TYPE k, KEY_TYPE v) { return comparator != null ? comparator.compare(k, v) : COMPAREABLE_TO_KEY(k, v);} + /** From CLR */ protected void rotateLeft(Entry KEY_VALUE_GENERIC_TYPE entry) { if(entry != null) { Entry KEY_VALUE_GENERIC_TYPE right = entry.right; @@ -806,6 +807,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } } + /** From CLR */ protected void rotateRight(Entry KEY_VALUE_GENERIC_TYPE entry) { if(entry != null) { Entry KEY_VALUE_GENERIC_TYPE left = entry.left; @@ -822,6 +824,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } } + /** From CLR */ protected void fixAfterInsertion(Entry KEY_VALUE_GENERIC_TYPE entry) { while(entry != null) { entry.updateHeight(); @@ -846,6 +849,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } } + /** From CLR */ protected void fixAfterDeletion(Entry KEY_VALUE_GENERIC_TYPE entry) { if(entry != null) { entry.updateHeight(); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/Map.template b/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/Map.template index fd9f70c3..17353125 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/Map.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/Map.template @@ -509,7 +509,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map=0;i--) - { - Assert.assertEquals(TEST_ARRAY[i], map.pollLastIntKey()); - } - Assert.assertEquals(0, map.size()); + Assert.assertEquals(map.pollLastIntKey(), 99); } @Test