Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package A3Q2;
  2.  
  3. /**
  4. * Tests DoubleProbeHashMap
  5. *
  6. * @author jameselder
  7. */
  8. public class testDoubleProbeHashMap {
  9.  
  10. public static void main(String[] args) throws Exception {
  11. AsciiReader marathonReader;
  12. Object[] Format = {Integer.class, String.class,
  13. String.class, String.class, String.class, String.class};
  14. Object[] result;
  15. //ProbeHashMap<String, MarathonRunner> marathonMap = new ProbeHashMap<>(7500);
  16. DoubleProbeHashMap<String, MarathonRunner> marathonMap = new DoubleProbeHashMap<>(7500);
  17. MarathonRunner marathonRunner;
  18.  
  19. try {
  20. //marathonReader = new AsciiReader("marathon.csv");
  21. marathonReader = new AsciiReader("marathon2017.csv");
  22. do {
  23. result = marathonReader.ReadLine(Format, ",");
  24. if (result != null) {
  25. marathonRunner = new MarathonRunner((Integer) result[0],
  26. (String) result[1], (String) result[2],
  27. (String) result[3], (String) result[4],
  28. (String) result[5]
  29. );
  30. //System.out.println(marathonRunner.toString());
  31. try { //use name and category as key
  32. marathonRunner = marathonMap.put((String) result[3] + " "
  33. + (String) result[4] + " " + (String) result[5], marathonRunner);
  34. if (marathonRunner != null) {
  35. System.out.println(marathonRunner.toString()); //print duplicates
  36. }
  37. } catch (Exception ex) {
  38. System.out.println("Incorrect: ProbeHashMap.put threw an exception.");
  39. }
  40. }
  41. } while (result != null);
  42. } catch (Exception x) {
  43. System.out.println("File not found");
  44. }
  45.  
  46. try {
  47. marathonRunner = marathonMap.get("Cartmell Greg M25-29");
  48. System.out.println(marathonRunner.toString());
  49. } catch (Exception ex) {
  50. System.out.println("Incorrect: DoubleProbeHashMap.get threw an exception.");
  51. }
  52. System.out.println("Total Probes: " + marathonMap.getTotalProbes());
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement