(String key)
| 23 | } |
| 24 | |
| 25 | public void inc(String key) { |
| 26 | Node cur = head; |
| 27 | int newFreq = 1; |
| 28 | if(map.containsKey(key)){ |
| 29 | cur = map.get(key); |
| 30 | newFreq = cur.freq + 1; |
| 31 | cur.keys.remove(key); |
| 32 | } |
| 33 | if(cur.next.freq == newFreq){ |
| 34 | cur.next.keys.add(key); |
| 35 | }else{ // insert a node with newFreq |
| 36 | Node node = new Node(newFreq); |
| 37 | node.keys.add(key); |
| 38 | Node nextNode = cur.next; |
| 39 | node.next = nextNode; |
| 40 | nextNode.prev = node; |
| 41 | cur.next = node; |
| 42 | node.prev = cur; |
| 43 | } |
| 44 | map.put(key, cur.next); |
| 45 | if(cur.keys.size()==0 && cur!=head){ |
| 46 | removeNode(cur); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public void dec(String key) { |
| 51 | Node cur = map.get(key); |
nothing calls this directly
no test coverage detected