Advertisement
heroofhyla

HashingTest

Sep 30th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. public static void main(String[] args){
  2.         ChainMap<PoorlyHashedKey, String> map = new ChainMap<>();
  3.        
  4.         PoorlyHashedKey p1 = new PoorlyHashedKey("AppleKey");
  5.         PoorlyHashedKey p2 = new PoorlyHashedKey("GrapeKey");
  6.         PoorlyHashedKey p3 = new PoorlyHashedKey("BananaKey");
  7.        
  8.         PoorlyHashedKey p1Duplicate = new PoorlyHashedKey("AppleKey");
  9.         PoorlyHashedKey p2Duplicate = new PoorlyHashedKey("GrapeKey");
  10.         PoorlyHashedKey p3Duplicate = new PoorlyHashedKey("BananaKey");
  11.         map.put(p1, "AppleValue");
  12.         map.put(p2, "GrapeValue");
  13.         map.put(p3, "BananaValue");
  14.        
  15.         System.out.println("Beginning test of original keys with values:");
  16.        
  17.         testKey(p1, map);
  18.         testKey(p2, map);
  19.         testKey(p3, map);
  20.        
  21.         System.out.println("Beginning test of duplicates of keys with values:");
  22.         testKey(p1Duplicate, map);
  23.         testKey(p2Duplicate, map);
  24.         testKey(p3Duplicate, map);
  25.     }
  26.    
  27.     public static void testKey(PoorlyHashedKey p, ChainMap<PoorlyHashedKey, String> map){
  28.         System.out.println(p + "(hashcode: " + p.hashCode() + ") -> " + map.get(p));
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement