How to make an Iterative loop in Map<Pair<Match,DatapathId>, FlowRuleStats>?

46 Views Asked by At

I work on floodlight controller. I have a map as
Map<Pair<Match,DatapathId>, FlowRuleStats>
and I just have DatapathId.

Here is some my code :

Map<Pair<Match,DatapathId>, FlowRuleStats> getFlowStats();
Map<Pair<Match, DatapathId>, FlowRuleStats> m;
m = switchStatistics.getFlowStats();

How can I make a loop and process all the element in the m?

1

There are 1 best solutions below

0
On

The map is keyed on Pair<Match, DatapathId> and evidently you don't have that. You only have DatapathId. Which means you can't do key based lookups. at all.

The only thing you can do is loop through the entire map:

for (var entry : m.entrySet()) {
    if (!entry.getKey().getRight().equals(datapathidYouHave)) continue;
    Pair<Match, DatapathId> md = entry.getKey();
    FlowRuleStats stats = entry.getValue();
    .....
}