I am trying to clean my code and want to used optimised approches in the code.
Currently I have hashmap of this type
private HashMap<String, ArrayList<allProperty>> fData;
So The data is coming from server in every 5 second. and I am updating this hashmap every 5 second something like this
fData.put("Student", allStudent);
fData.put("Emp", allEmp);
fData.put("Other", allOther);
So from allproperty class object, there is marks fields and I am trying to extract that marks field for all key and creating new arraylist of integer so that I can append the marks in created arraylist by every 5 second.
I was using different arraylist for each student, emp and other before and it was working fine but it seems like alot of repeation of code. That is why I am trying to achieve it with hash map
I am trying soemthing like this but it is not appending data ...
for (String type: allTypes) {
if(fData.get(type).size() > 0){
arraySort(fData.get(type));
temp = new ArrayList<Integer>();
temp.add(fData.get(type).get(0).marks);
}
cData.put(type, temp);
cType is hashMap of type given below and
private HashMap<String, ArrayList<Integer>> cData;
where allTypes is
signalTypes.add("Student");
signalTypes.add("Emp");
signalTypes.add("Other");
at the end I want three new arraylist with key and able to append data in every 5 seconds. Thanks
fDataandmarks.