commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/map LRUMap.java
Date Sun, 25 Apr 2004 23:30:07 GMT
scolebourne    2004/04/25 16:30:07

  Modified:    collections/src/java/org/apache/commons/collections/map
                        LRUMap.java
  Log:
  Use isFull() from addMapping() for better subclassing ability
  from Mike Pettypiece
  
  Revision  Changes    Path
  1.12      +6 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/map/LRUMap.java
  
  Index: LRUMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/LRUMap.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LRUMap.java	25 Apr 2004 23:27:43 -0000	1.11
  +++ LRUMap.java	25 Apr 2004 23:30:07 -0000	1.12
  @@ -46,6 +46,7 @@
    * @author James Strachan
    * @author Morgan Delagrange
    * @author Stephen Colebourne
  + * @author Mike Pettypiece
    */
   public class LRUMap
           extends AbstractLinkedMap implements BoundedMap, Serializable, Cloneable {
  @@ -166,6 +167,9 @@
        * <p>
        * This implementation checks the LRU size and determines whether to
        * 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 hashCode  the hash code of the key to add
  @@ -173,7 +177,7 @@
        * @param value  the value to add
        */
       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);
           } else {
               super.addMapping(hashIndex, hashCode, key, value);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message