Advertisement
Guest User

Untitled

a guest
Jul 30th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package xyz.serega100.test;
  2.  
  3. import java.util.HashMap;
  4. import java.util.HashSet;
  5.  
  6. public class MainClass {
  7.  
  8.  
  9.     public static void main(String[] args) {
  10.         // ДОБАВЛЕНИЕ ЭЛЕМЕНТА В МАП
  11. //        HashMap<String, Boolean> blackmap = new HashMap<>();
  12. //
  13. //
  14. //        long startTime = System.nanoTime();
  15. //        blackmap.put("lol", null);
  16. //        long estimatedTime = System.nanoTime() - startTime;
  17. //        System.out.println("map: " + estimatedTime);
  18.         // ДОБАВЛЕНИЕ ЭЛЕМЕНТА В СЕТ
  19. //        HashSet<String> blackset = new HashSet<>();
  20. //
  21. //        long startTime2 = System.nanoTime();
  22. //        blackset.add("lol");
  23. //        long estimatedTime2 = System.nanoTime() - startTime2;
  24. //        System.out.println("set: " + estimatedTime2);
  25.  
  26.         // ПРОВЕРКА ЭЛЕМЕНТА В МАПЕ
  27.         HashMap<String, Boolean> blackmap = new HashMap<>();
  28.  
  29.         blackmap.put("lol", null);
  30.         long startTime = System.nanoTime();
  31.  
  32.         if(blackmap.containsKey("lol")){
  33.             long estimatedTime = System.nanoTime() - startTime;
  34.             System.out.println("map: " + estimatedTime);
  35.         }
  36.  
  37.         // ПРОВЕРКА ЭЛЕМЕНТА В СЕТЕ
  38. //        HashSet<String> blackset = new HashSet<>();
  39. //        blackset.add("lol");
  40. //        long startTime2 = System.nanoTime();
  41. //        if(blackset.contains("lol")) {
  42. //            long estimatedTime2 = System.nanoTime() - startTime2;
  43. //            System.out.println("set: " + estimatedTime2);
  44. //        }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.     }
  51.  
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement