if(callingflag)
{
int calledUserTp = totalPointsByUserid(callinguserid,jokercard);
System.out.println("Total Points of the User Who has made a Call is ::"+calledUserTp);
HashMap<Integer,Integer> useridTotalRankMap = totalPointsforEveryUser(jokercard);
HashMap<Integer,Integer> useridTotalRankMapSorted = new HashMap<Integer, Integer>();
useridTotalRankMapSorted = (HashMap<Integer, Integer>) sortByComparator(useridTotalRankMap);
for(Map.Entry<Integer, Integer> entry :useridTotalRankMapSorted.entrySet())
{
System.out.println( entry.getKey() +"----"+entry.getValue());
if(entry.getKey() == callinguserid )
{
System.out.println( "GOOD CALL");
break;
}
}
}
上記の for ループを回避するにはどうすればよいですか。useridTotalRankMapSorted はマップです
useridTotalRankMap と呼ばれるこのハッシュマップがあり、いくつかの合計ポイントを持つユーザー ID があります。
関係がない場合、calleruserid に対応する値がそのハッシュマップで最小かどうかを確認したいと思います。
あると言う
1:4
4:7
3:7
2:5
および calleruserid = 1 。key=1、つまり 4 の値が最小の場合、「good call」と出力します。
私が今はっきりしていることを願っています。
コーディング方法に変更はありますか?