MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / dec

Method dec

src/class035/Code07_AllO1.java:78–96  ·  view source on GitHub ↗
(String key)

Source from the content-addressed store, hash-verified

76 }
77
78 public void dec(String key) {
79 Bucket bucket = map.get(key);
80 if (bucket.cnt == 1) {
81 map.remove(key);
82 } else {
83 if (bucket.last.cnt == bucket.cnt - 1) {
84 map.put(key, bucket.last);
85 bucket.last.set.add(key);
86 } else {
87 Bucket newBucket = new Bucket(key, bucket.cnt - 1);
88 map.put(key, newBucket);
89 insert(bucket.last, newBucket);
90 }
91 }
92 bucket.set.remove(key);
93 if (bucket.set.isEmpty()) {
94 remove(bucket);
95 }
96 }
97
98 public String getMaxKey() {
99 return tail.last.set.iterator().next();

Callers

nothing calls this directly

Calls 6

removeMethod · 0.95
insertMethod · 0.95
getMethod · 0.45
putMethod · 0.45
addMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected