im writing a program that parses data from a log file. each line in the log is either a process wit a start time or an end time for one of the started processes. i already figured out how to print all the start times but i cant wrap my head around how to pull out the end time for each of the started processes. i want to put all the end times in a hashmap and iterate thru to find the end times for each process. the end times are usually within an hour of the start time. thanks in advance
posted 8 years ago
I assume these processes have a unique identifier (i.e. the process ID) ? Without that you have nothing to link the times by.
You could do this one of two ways. Store an array (2 elements) in the HashMap where the process ID maps to the array:
To add a start time:
To add the end time:
You could use two parallel HashMaps too, but if you know it's alwayts going to be just two times for start and end that may be a bit overkill.
The subject of your thread suggested that you wanted to know how to iterate over the map, but from your message I'm guessing you already know that?