Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public class FrequencyCounter{
  2. private final ConcurrentHashMap<Integer,Long> frequencenyMap = new ConcurrentHashMap<>();
  3.  
  4. public void processRequest(Request request){
  5. frequencenyMap.merge(request.type, 0L, (v, d) -> v+1);
  6. }
  7.  
  8. public void clearMap(){
  9. frequencenyMap.clear();
  10. }
  11.  
  12. public Map<Integer,Long> getMap(){
  13. return ImmutableMap.copyOf(frequencenyMap);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement