1
2
3
4
5
6 package io.github.olyutorskii.aletojio.idling;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 public class PopCntMonitor extends AbstractRndMonitor {
22
23 private final int popCt;
24
25
26
27
28
29
30
31
32 public PopCntMonitor(int pop) throws IllegalArgumentException {
33 super();
34
35 if (pop < 0 || Integer.SIZE < pop) {
36 throw new IllegalArgumentException();
37 }
38
39 this.popCt = pop;
40
41 return;
42 }
43
44
45
46
47
48 @Override
49 protected void resetImpl() {
50 assert true;
51 }
52
53
54
55
56
57
58
59 @Override
60 protected boolean probeImpl(int iVal) {
61 boolean result =
62 Integer.bitCount(iVal) == this.popCt;
63 return result;
64 }
65
66 }