Use isFull() from addMapping() for better subclassing ability
from Mike Pettypiece git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc680b3f48
commit
156ebc8e09
|
@ -41,11 +41,12 @@ import org.apache.commons.collections.BoundedMap;
|
||||||
* <code>ResettableIterator</code> and calling <code>reset()</code>.
|
* <code>ResettableIterator</code> and calling <code>reset()</code>.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0 (previously in main package v1.0)
|
* @since Commons Collections 3.0 (previously in main package v1.0)
|
||||||
* @version $Revision: 1.11 $ $Date: 2004/04/25 23:27:43 $
|
* @version $Revision: 1.12 $ $Date: 2004/04/25 23:30:07 $
|
||||||
*
|
*
|
||||||
* @author James Strachan
|
* @author James Strachan
|
||||||
* @author Morgan Delagrange
|
* @author Morgan Delagrange
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
|
* @author Mike Pettypiece
|
||||||
*/
|
*/
|
||||||
public class LRUMap
|
public class LRUMap
|
||||||
extends AbstractLinkedMap implements BoundedMap, Serializable, Cloneable {
|
extends AbstractLinkedMap implements BoundedMap, Serializable, Cloneable {
|
||||||
|
@ -166,6 +167,9 @@ public class LRUMap
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation checks the LRU size and determines whether to
|
* This implementation checks the LRU size and determines whether to
|
||||||
* discard an entry or not using {@link #removeLRU(LinkEntry)}.
|
* discard an entry or not using {@link #removeLRU(LinkEntry)}.
|
||||||
|
* <p>
|
||||||
|
* From Commons Collections 3.1 this method uses {@link #isFull()} rather
|
||||||
|
* than accessing <code>size</code> and <code>maxSize</code> directly.
|
||||||
*
|
*
|
||||||
* @param hashIndex the index into the data array to store at
|
* @param hashIndex the index into the data array to store at
|
||||||
* @param hashCode the hash code of the key to add
|
* @param hashCode the hash code of the key to add
|
||||||
|
@ -173,7 +177,7 @@ public class LRUMap
|
||||||
* @param value the value to add
|
* @param value the value to add
|
||||||
*/
|
*/
|
||||||
protected void addMapping(int hashIndex, int hashCode, Object key, Object value) {
|
protected void addMapping(int hashIndex, int hashCode, Object key, Object value) {
|
||||||
if (size >= maxSize && removeLRU(header.after)) {
|
if (isFull() && removeLRU(header.after)) {
|
||||||
reuseMapping(header.after, hashIndex, hashCode, key, value);
|
reuseMapping(header.after, hashIndex, hashCode, key, value);
|
||||||
} else {
|
} else {
|
||||||
super.addMapping(hashIndex, hashCode, key, value);
|
super.addMapping(hashIndex, hashCode, key, value);
|
||||||
|
|
Loading…
Reference in New Issue