This is a helper factory class that allows us to test different bucket types without having to write a separate test for each one. You don't need to understand how this works. Please don't modify this class unless you REALLY know what you're doing. @author Noah Adhikari, Spring 2023
| 11 | * @author Noah Adhikari, Spring 2023 |
| 12 | */ |
| 13 | public class MyHashMapFactory { |
| 14 | |
| 15 | /** Returns a MyHashMap with the specified bucket type. |
| 16 | * @param bucketType the type of bucket to use |
| 17 | */ |
| 18 | public static <K, V> MyHashMap<K, V> createBucketedMap(Class<? extends Collection> bucketType) { |
| 19 | return new MyHashMap<>() { |
| 20 | @Override |
| 21 | protected Collection<Node> createBucket() { |
| 22 | try { |
| 23 | return bucketType.getConstructor().newInstance(); |
| 24 | } catch (Exception e) { |
| 25 | throw new RuntimeException(e); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | // for the timing tests |
| 30 | @Override |
| 31 | public String toString() { |
| 32 | return "MyHashMap with " + bucketType.getSimpleName() + " buckets"; |
| 33 | } |
| 34 | }; |
| 35 | } |
| 36 | } |
nothing calls this directly
no outgoing calls
no test coverage detected