|
1 | | -import java.util.HashMap; |
2 | | -import java.util.Iterator; |
3 | | -import java.util.Map; |
| 1 | +import com.google.gson.Gson; |
| 2 | + |
| 3 | +import java.util.*; |
| 4 | +import java.util.stream.IntStream; |
4 | 5 |
|
5 | 6 | /** |
6 | 7 | * @author TommyYang on 2019-04-12 |
7 | 8 | */ |
8 | 9 | public class Test { |
9 | 10 |
|
10 | | - public static void main(String[] args){ |
11 | | - testDelItemFromMap(); |
| 11 | + public static void main(String[] args) throws InterruptedException { |
| 12 | +// testDelItemFromMap(); |
| 13 | + |
| 14 | + List<Integer> aList = new ArrayList<>(1000); |
| 15 | + IntStream.range(0, 999).forEach(index -> aList.add(index)); |
| 16 | + Set<Integer> res = new HashSet<>(); |
| 17 | + aList.parallelStream().forEach(i -> res.add(i)); |
| 18 | + aList.parallelStream().forEach(i -> res.add(i)); |
| 19 | + |
| 20 | + System.out.println(res.size()); |
12 | 21 | } |
13 | 22 |
|
14 | 23 |
|
| 24 | + static class B { |
| 25 | + private int id; |
| 26 | + private boolean inWhiteList; |
| 27 | + |
| 28 | + public B(int id) { |
| 29 | + this.id = id; |
| 30 | + } |
| 31 | + |
| 32 | + public int getId() { |
| 33 | + return id; |
| 34 | + } |
| 35 | + |
| 36 | + public void setId(int id) { |
| 37 | + this.id = id; |
| 38 | + } |
| 39 | + |
| 40 | + public boolean isInWhiteList() { |
| 41 | + return inWhiteList; |
| 42 | + } |
| 43 | + |
| 44 | + public void setInWhiteList(boolean inWhiteList) { |
| 45 | + this.inWhiteList = inWhiteList; |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public String toString() { |
| 50 | + return "B{" + |
| 51 | + "id=" + id + |
| 52 | + ", inWhiteList=" + inWhiteList + |
| 53 | + '}'; |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + static class A { |
| 58 | + private Integer customerId; |
| 59 | + |
| 60 | + private Integer shopId; |
| 61 | + |
| 62 | + private Integer moduleId; |
| 63 | + |
| 64 | + private Date beginTime; |
| 65 | + |
| 66 | + private Date endTime; |
| 67 | + |
| 68 | + public A(Integer customerId, Integer shopId, Integer moduleId, Date beginTime, Date endTime) { |
| 69 | + this.customerId = customerId; |
| 70 | + this.shopId = shopId; |
| 71 | + this.moduleId = moduleId; |
| 72 | + this.beginTime = beginTime; |
| 73 | + this.endTime = endTime; |
| 74 | + } |
| 75 | + } |
| 76 | + |
15 | 77 | public static void testDelItemFromMap(){ |
16 | 78 | Map<String, String> map = new HashMap<String, String>(); |
17 | 79 | map.put("aa", "aa"); |
|
0 commit comments