开发者

SortedMap with multiple fields for keys and values

开发者 https://www.devze.com 2023-01-11 04:12 出处:网络
I need to have a sortedMap with these fields for each key [srcAddr, dstAddr, srcPort, dstPort, protocol] (this is corresponding to a flow)

I need to have a sortedMap with these fields for each key [srcAddr, dstAddr, srcPort, dstPort, protocol] (this is corresponding to a flow)

then this key contains a list of values each containing some fields. such as: packetLenghth,timeArrival for packet 1 packetLength, timeArrival for packe开发者_JAVA百科t 2 . . . and so on.

In other words each packet is examined whether it belongs to a Flow or not based on those 5 mentioned fields. then for that particular packet some informarion will be extracted. for the next packet, if it belongs to that Flow, a new flow wont be added but information about that packet will be added.

i was thinking of having to separate classes myKeys and myValues each with desired fields. myKeys need to implement compareTo, hashCode, equal.

but i dont know if im right. can anyone help me with it please?


Your solution will work. Having Separate classes for your keys and values will allow you to use a sorted map that maps one to the other as long as the key class implements Comparable which it sounds like is your plan.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号