Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xyz.serega100.test;
- import java.util.HashMap;
- import java.util.HashSet;
- public class MainClass {
- public static void main(String[] args) {
- // ДОБАВЛЕНИЕ ЭЛЕМЕНТА В МАП
- // HashMap<String, Boolean> blackmap = new HashMap<>();
- //
- //
- // long startTime = System.nanoTime();
- // blackmap.put("lol", null);
- // long estimatedTime = System.nanoTime() - startTime;
- // System.out.println("map: " + estimatedTime);
- // ДОБАВЛЕНИЕ ЭЛЕМЕНТА В СЕТ
- // HashSet<String> blackset = new HashSet<>();
- //
- // long startTime2 = System.nanoTime();
- // blackset.add("lol");
- // long estimatedTime2 = System.nanoTime() - startTime2;
- // System.out.println("set: " + estimatedTime2);
- // ПРОВЕРКА ЭЛЕМЕНТА В МАПЕ
- HashMap<String, Boolean> blackmap = new HashMap<>();
- blackmap.put("lol", null);
- long startTime = System.nanoTime();
- if(blackmap.containsKey("lol")){
- long estimatedTime = System.nanoTime() - startTime;
- System.out.println("map: " + estimatedTime);
- }
- // ПРОВЕРКА ЭЛЕМЕНТА В СЕТЕ
- // HashSet<String> blackset = new HashSet<>();
- // blackset.add("lol");
- // long startTime2 = System.nanoTime();
- // if(blackset.contains("lol")) {
- // long estimatedTime2 = System.nanoTime() - startTime2;
- // System.out.println("set: " + estimatedTime2);
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement