SortedMap with multiple fields for keys and values

I need to have sortedMap with these fields for each key [srcAddr, dstAddr, srcPort, dstPort, protocol] (this corresponds to the stream)

then this key contains a list of values, each of which contains some fields. such as: packetLenghth, timeArrival for packet 1 packetLength, timeArrival for packet 2,,, etc.

In other words, each packet is checked whether it belongs to the stream or not based on these 5 mentioned fields. then some information will be extracted for this particular package. for the next package, if it belongs to this stream, a new stream will not be added, but information about this package will be added.

I thought about the need to separate myKeys and myValues ​​classes with the required fields. myKeys need to implement compareTo, hashCode equal to.

but I do not know if it is right for them. can anyone help me with it?

+1
source share
1 answer

Your solution will work. Having separate classes for your keys and values ​​will allow you to use a sorted map that maps it to each other if the class class implements Comparable, which, in its opinion, is your plan.

+2
source

All Articles