I have a method that is sleeping through which I get a list as shown below.
List<abcObject> aaList= session.createCriteria(abcObject.class)
now when checking, I found that the list type has an object type, since api criteria returns us a list of object types
Now the list I get is the following:
t_id value
11 3
12 20
14 60
15 17 ------->(3+20+60+17 =100),here min =11 & max =15
18 40
22 20
33 40
45 20 ---------->(40+20+40+20 =100),here min =18 & max =45
Now, please consult, since I need to iterate over the list so that if the number of values ββreaches 100, then a separate map must be created, which will be min and the value will be max, now the map has a row type
min max
11 15
18 45
and also be careful that this parameter, on which division equal to 100 was performed, can sometimes be set to 60, therefore this separation parameter needs to be set
, , , , min max , .
min max
11 15
18 45
, , java, .
-, .
final int BARRIER = 100;
List<abcObject> minMaxs = new List<abcObject>();
int sum = 0;
int min = 0;
for (abcObject obj: aaList) {
if (sum == 0) {
min = obj.getT_id();
}
sum += obj.getValue();
if (sum >= BARRIER) {
minMaxs.add(new abcObject(min, obj.getT_id()));
min = 0;
sum = 0;
}
}
user2988384