[
https://issues.apache.org/jira/browse/OPENNLP-887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15761826#comment-15761826
]
ASF GitHub Bot commented on OPENNLP-887:
----------------------------------------
GitHub user smarthi opened a pull request:
https://github.com/apache/opennlp/pull/9
OPENNLP-887: Replace the Cache class with a LinkedHashMap
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/smarthi/opennlp OEPNNLP-887
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/opennlp/pull/9.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #9
----
commit 1637683f611841aced5934cec06054d25b33a302
Author: smarthi <[email protected]>
Date: 2016-12-19T17:51:54Z
OPENNLP-887: Replace the Cache class with a LinkedHashMap
----
> Replace the Cache class with a LinkedHashMap
> --------------------------------------------
>
> Key: OPENNLP-887
> URL: https://issues.apache.org/jira/browse/OPENNLP-887
> Project: OpenNLP
> Issue Type: Improvement
> Reporter: Joern Kottmann
> Assignee: Suneel Marthi
> Priority: Minor
> Fix For: 1.7.0
>
>
> The existing cache implementation could be replaced with
> java.util.LinkedHashMap. This change would replace our custom implementation
> with an implementation which will be maintained for us.
> To have the same behaviour as our implementation LinkedHashMap must be
> subclasses. The LinkedHashMap.removeEldestEntry must be overwritten and
> return true if size limit is reached.
> This could be something like this:
> import java.util.LinkedHashMap;
> import java.util.Iterator;
> import java.util.Map;
> public class Cache<K, V> extends LinkedHashMap<K,V> {
> private final int capacity;
> public Cache(int capacity) {
> this.capacity = capacity;
> }
> @Override
> protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
> return this.size() > this.capacity;
> }
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)