当前位置 : 主页 > 编程语言 > c++ >

3个对象(可能为空),以某个属性为key,key重复的话选最高权重的

来源:互联网 收集:自由互联 发布时间:2021-06-30
gistfile1.txt // 三个奖励是否为存在重复获奖用户, 有则取最高奖励的那个奖励Map rewardMap = new HashMap (3); ActivityNovReward[] rewardArray = {firstReward,lastReward,maxReward}; ActivityNovReward activityNovReward
gistfile1.txt
// 三个奖励是否为存在重复获奖用户, 有则取最高奖励的那个奖励
Map
 
   rewardMap = new HashMap
  
   (3); ActivityNovReward[] rewardArray = {firstReward,lastReward,maxReward}; ActivityNovReward activityNovReward = null ; for(ActivityNovReward reward :rewardArray ){ if(reward == null){ continue; } activityNovReward = rewardMap.get(reward.getUserId()); if(activityNovReward != null){ //存在重复奖励, reward 和 activityNovReward 的用户id 是一样的 if(reward.getRewardAmt().compareTo(activityNovReward.getRewardAmt()) == 1){ // reward 奖励 大于 activityNovReward , 用户 reward 覆盖掉 activityNovReward rewardMap.put(reward.getUserId(), reward); } }else{ rewardMap.put(reward.getUserId(), reward); } }
  
 
网友评论