-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert to Kotlin to fix the packaging error
- Loading branch information
Showing
1 changed file
with
3 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author weishu | ||
* @date 2023/10/9. | ||
*/ | ||
public class MaxSizeHashMap<K, V> extends LinkedHashMap<K, V> { | ||
private final int maxSize; | ||
|
||
public MaxSizeHashMap(int maxSize) { | ||
this.maxSize = maxSize; | ||
} | ||
|
||
@Override | ||
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) { | ||
return size() > maxSize; | ||
class MaxSizeHashMap<K, V>(private val maxSize: Int) : LinkedHashMap<K, V>() { | ||
override fun removeEldestEntry(eldest: Map.Entry<K, V>): Boolean { | ||
return size > maxSize | ||
} | ||
} |