From ab289774fdd15ce76f764e33dec00c5e3df8b17c Mon Sep 17 00:00:00 2001
From: lipian <lipian@cs.washington.edu>
Date: Tue, 14 Apr 2020 16:34:45 -0400
Subject: [PATCH] Improving generics with respect to NGrams

---
 .../trees/BinarySearchTree.java               |  2 +-
 .../interfaces/misc/ComparableDictionary.java |  2 +-
 src/datastructures/dictionaries/AVLTree.java  |  2 +-
 .../ckpt1/NGramToNextChoicesMapTests.java     | 20 +++++++++----------
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/cse332/datastructures/trees/BinarySearchTree.java b/src/cse332/datastructures/trees/BinarySearchTree.java
index 92fecb7..c045ca3 100644
--- a/src/cse332/datastructures/trees/BinarySearchTree.java
+++ b/src/cse332/datastructures/trees/BinarySearchTree.java
@@ -13,7 +13,7 @@ import datastructures.worklists.ArrayStack;
  * BinarySearchTree implements the ComparableDictionary interface using a binary
  * search tree. Notice that the key type must be Comparable.
  */
-public class BinarySearchTree<K extends Comparable<K>, V>
+public class BinarySearchTree<K extends Comparable<? super K>, V>
         extends ComparableDictionary<K, V> {
     // The root of the BST. Root is null if and only if the tree is empty.
     protected BSTNode root;
diff --git a/src/cse332/interfaces/misc/ComparableDictionary.java b/src/cse332/interfaces/misc/ComparableDictionary.java
index d65c900..7a2ee2f 100644
--- a/src/cse332/interfaces/misc/ComparableDictionary.java
+++ b/src/cse332/interfaces/misc/ComparableDictionary.java
@@ -10,6 +10,6 @@ package cse332.interfaces.misc;
  *
  * @author Adam Blank
  */
-public abstract class ComparableDictionary<K extends Comparable<K>, V>
+public abstract class ComparableDictionary<K extends Comparable<? super K>, V>
         extends DeletelessDictionary<K, V> {
 }
diff --git a/src/datastructures/dictionaries/AVLTree.java b/src/datastructures/dictionaries/AVLTree.java
index 02f5310..2d5de2a 100644
--- a/src/datastructures/dictionaries/AVLTree.java
+++ b/src/datastructures/dictionaries/AVLTree.java
@@ -28,6 +28,6 @@ import cse332.datastructures.trees.BinarySearchTree;
  * 6. Do NOT override the toString method. It is used for grading.
  */
 
-public class AVLTree<K extends Comparable<K>, V> extends BinarySearchTree<K, V>  {
+public class AVLTree<K extends Comparable<? super K>, V> extends BinarySearchTree<K, V>  {
     // TODO: Implement me!
 }
diff --git a/src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java b/src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
index a82e790..85d65dc 100644
--- a/src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
+++ b/src/tests/gitlab/ckpt1/NGramToNextChoicesMapTests.java
@@ -1,19 +1,19 @@
 package tests.gitlab.ckpt1;
 
+import cse332.datastructures.containers.Item;
+import cse332.datastructures.trees.BinarySearchTree;
+import cse332.types.NGram;
+import org.junit.Test;
+import p2.wordsuggestor.NGramToNextChoicesMap;
+
 import java.util.Arrays;
 import java.util.Comparator;
-import java.util.TreeMap;
 import java.util.Map;
-import java.util.function.Supplier;
+import java.util.TreeMap;
 
-import cse332.datastructures.containers.Item;
-import cse332.interfaces.misc.Dictionary;
-import cse332.types.AlphabeticString;
-import cse332.types.NGram;
-import cse332.datastructures.trees.BinarySearchTree;
-import p2.wordsuggestor.NGramToNextChoicesMap;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 public class NGramToNextChoicesMapTests {
     private NGramToNextChoicesMap init() {
-- 
GitLab