-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathBins.java
More file actions
28 lines (24 loc) · 840 Bytes
/
Bins.java
File metadata and controls
28 lines (24 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.HashMap;
import java.util.Map;
public class Bins {
//map<key,value>
Map<Integer, Integer> mapOfBins = new HashMap<>();
private Integer minimumNumber;
private Integer maximumNumber;
public Bins(int minimumNumber, int maximumNumber) {
this.minimumNumber = minimumNumber;
this.maximumNumber = maximumNumber;
for (int i = minimumNumber; i <= maximumNumber; i++) {
mapOfBins.put(i, 0);
}
}
public Integer getBin(int binNumber) {
return mapOfBins.get(binNumber);
}
public void incrementBin(Integer binNumber) {
if (binNumber >= this.minimumNumber && binNumber <= this.maximumNumber) {
Integer currentBinResult = this.getBin(binNumber);
this.mapOfBins.put(binNumber, currentBinResult + 1);//
}
}
}